Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    Regular Coder
    Join Date
    Jan 2005
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Pass values using Javascript

    I have a form and want to use Javascript to pass the values from one page to the other. I am able to get the first pass to work but I am not sure what should go in the value of the hidden fields.

    Any help is greatly appreciated.

    Page 1:
    Code:
    <html>
    <head>
    <title></title>
    </head>
    
    <body>
    
    <form name="myform" method="get" action="test2.html">
    Email: <input type="text" name="Email">
    <input type="hidden" name="ID" value="12345">
    <input type="submit" value="Submit">
    </form>
    
    </body>
    </html>
    Page 2:
    Code:
    <html>
    <head>
    <title></title>
    
    <script LANGUAGE="JavaScript">
    function decodeSearchString() {
       var nameValue = new Array();
       var searchStr = unescape(location.search.substring(1));
       if (searchStr) {
           var formElement = searchStr.split("&");
           var tmpArray = new Array();
           for (k = 0; k < formElement.length; k++) {
                tmpArray = formElement[k].split("=");
                nameValue[tmpArray[0]] = tmpArray[1];
           }
       }
       return nameValue
    }
    
    var srchData = decodeSearchString();
    </SCRIPT>
    </head>
    
    <body>
    
    <form name="myform" method="get" action="test3.html">
    <SCRIPT LANGUAGE="JavaScript1.2">
    <!--
    	document.write("Email: " + srchData.Email);
    	document.write("<br>");
    	document.write("ID: " + srchData.ID);
    	document.write("<br>");
    //-->
    </script>
    
    Name: <input type="text" name="Name">
    
    
    <input type="hidden" name="Email" value="???">
    <input type="hidden" name="ID" value="???">
    <input type="submit" value="Submit">
    </form>
    
    </body>
    </html>
    Page 3:
    Code:
    <html>
    <head>
    <title></title>
    
    <script LANGUAGE="JavaScript">
    function decodeSearchString() {
       var nameValue = new Array();
       var searchStr = unescape(location.search.substring(1));
       if (searchStr) {
           var formElement = searchStr.split("&");
           var tmpArray = new Array();
           for (k = 0; k < formElement.length; k++) {
                tmpArray = formElement[k].split("=");
                nameValue[tmpArray[0]] = tmpArray[1];
           }
       }
       return nameValue
    }
    
    var srchData = decodeSearchString();
    </SCRIPT>
    </head>
    
    <body>
    
    <form name="myform" method="post" action="">
    <SCRIPT LANGUAGE="JavaScript1.2">
    <!--
    	document.write("Email: " + srchData.Email);
    	document.write("<br>");
    	document.write("ID: " + srchData.ID);
    	document.write("<br>");
    	document.write("Name: " + srchData.Name);
    	document.write("<br><br>");
    //-->
    </script>
    
    <input type="submit" value="Submit">
    </form>
    
    </body>
    </html>
    Last edited by dlg0351; 03-17-2005 at 01:52 PM.

  • #2
    Regular Coder
    Join Date
    Jan 2005
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    Anyone have any suggestions?

  • #3
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by PROWEBWORKS.NET
    I am able to get the first pass to work but I am not sure what should go in the value of the hidden fields.
    What is that supposed to mean?
    *this message will self destruct in n-seconds*

  • #4
    Regular Coder
    Join Date
    Jan 2005
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What do you mean what is that supposed to mean?

  • #5
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    exactly
    *this message will self destruct in n-seconds*

  • #6
    Regular Coder
    Join Date
    Jan 2005
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Do you have a suggestion to answer my original question?

  • #7
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I suggest that you restate it, because apparently I'm not the only one who doesn't quite understand what it was...
    *this message will self destruct in n-seconds*

  • #8
    Regular Coder
    Join Date
    Jan 2005
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    I am trying to pass values from one html page to another using javascript. The code is three different html pages that will be viewed in sequence.

    The first page an email address is entered in an input box and an id is stored and passed to the second page.

    The second page the email address and id or displayed and an input is there for a name to be entered and all three are passed to the third page.

    The third page displays all three, email, id and name.

    My problem is that I am not sure what goes in the value part of the hidden fields on page two:

    Code:
    <input type="hidden" name="Email" value="???">
    <input type="hidden" name="ID" value="???">
    Do this explanation help?

  • #9
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, that's understandable--though I don't have an immediate answer.
    *this message will self destruct in n-seconds*

  • #10
    Regular Coder
    Join Date
    Jan 2005
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No problem, thanks for your help.

  • #11
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    You are either going to have to use cookies or a query string to pass values from one page to the next.

    It would be a lot easier with a server side language.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #12
    Regular Coder
    Join Date
    Jan 2005
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    If I could use a server side language I would, unfortunately the client I am doing this for down not pay for PHP with their hosting package.

    I am not familiar with cookies or query strings, any direction or suggestions for this?

  • #13
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Last edited by codegoboom; 03-18-2005 at 02:37 AM. Reason: obviously
    *this message will self destruct in n-seconds*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •