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

Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Hi,

    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.

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

    Comment


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

      .....Willy

      Comment


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

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

        Thanks again

        Comment


        • #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

          Comment


          • #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">
            <p>
            <input type="checkbox" name="checkbox1">
            <input type="text" name="myvar">
            </p>
            <p>
            <input type="checkbox" name="checkbox2">
            <input type="text" name="myvar2">
            </p>
            <p>
            <input type=submit>
            </p>
            </form>

            and then the next page:

            <script>
            twdlength = window.location.search.length
            myvar=window.location.search.substring(7,twdlength);

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

            </script>

            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

            Comment


            • #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.
              Glenn
              vBulletin Mods That Rock!

              Comment

              Working...
              X