Web Analytics Made Easy -
StatCounter carrying form variables to another page....Pls HELP !!! - CodingForum


No announcement yet.

carrying form variables to another page....Pls HELP !!!

  • Filter
  • Time
  • Show
Clear All
new posts

  • carrying form variables to another page....Pls HELP !!!


    I'm having some problems with a form and javascript. What I would like to do is carry variables from the text boxes into the next page and display them like a receipt of transaction sort of thing. For example, the user fills in the form, and presses submit, and the action page, displays the user's inputted variables, in text format.

    How can I do this dynamically?

    Thanks in advance

  • #2
    you need to pass them through a query string or store them in a cookie (bad since user can disable) to do it since you are not using a server side langauge.

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


    • #3
      You can find several examples of passing data from page to page here.



      • #4
        Thanks guys..........

        I really appreciate the help, I give this stuff a try and let you know how it goes......

        Thanks again


        • #5
          You can find several examples of passing data from page to page here
          The particular example you linked to makes no considerations for escaping special characters. So if the name or value you wish to pass contains any of these characters then the script will break. Likewise, the query string parser foudn on the same page will also fail for many valid query strings. While I do not currently know of an alterative script for passing values through the window name, you can find an alterative query string parser at http://www.webdeveloper.com/forum/sh...d.php?t=162208
          Last edited by joh6nn; Oct 3, 2007, 08:04 PM. Reason: updated url at user's request


          • #6
            I am having so many problems at the moment!!

            I have managed to pass a variable from one window to another, in a text box. But I can't seem to do it for multiple boxes, where each text box has a checkbox next to it.

            Basically, I need to only pass the text box variables that have a ticked check box next to the text box. Here's my form's script:

            The first page:

            <form method="GET" action="nextpage.html">
            <input type="checkbox" name="checkbox1">
            <input type="text" name="myvar">
            <input type="checkbox" name="checkbox2">
            <input type="text" name="myvar2">
            <input type=submit>

            and then the next page:

            twdlength = window.location.search.length

            <form name="whatever">
            <input type="text" name="newvar" value=myvar>
            document.forms["whatever"].newvar.value = myvar;


            This next page coding only works if the first page just has a text box and a submit button on it. I need it to display the selected items only, which have been ticked and a value has been entered for into the respective text box(s).

            How can the next page's code be altered in order to achieve this?

            Thanks alot


            • #7
              Use the URL parser script linked from above posts. And remember that unchecked checkboxes are not sent to the URL so you should check if checkbox1 or checkbox2 exists in the URL before reading the value of the corresponding text field.
              vBulletin Mods That Rock!