passing form variables between pages - not another searchstring question :)

Discussion in 'Javascript' started by williamroy, Nov 16, 2005.

  1. williamroy

    williamroy Guest

    Hello,

    I've got a form that runs over 5 pages. I need the last page submit
    button to post all of the answers at one time from the previous 5 pages
    (to another server). I'd like to see the last page of the form post all
    answers in clean ?= format as though all form elements were from one
    page.

    I use GET to pass name/value pairs from the first to the second page
    because no JS is needed to use Get once, and then I use a single hidden
    form element on each following page to store all of the
    "searchstring(1)" into it. That way, it gets passed along with the new
    form elements.

    As you can imagine though, my URL gets pretty messy and really long. I
    do not want to use cookies because of compatility limitations. Frames
    are out of the question because I only have access to body content on
    each templated page. How can I get the result I want?

    I figure I could do something to the content before I set it to the
    hidden value (like split(&)), but that only cleans it up a little. And
    then I'm unescaping and other weird stuff. I still have spaces in
    textareas, and @ characters in email addresses don't get cleaned up by
    unescape for some reason.

    Is it possible to make an array of the previous passed variables, then
    cycle through an array in a for-loop and automatically make more hidden
    fields with values loaded? Do button types from the previous page
    matter? I could maybe make them all text fields. The names of the text
    fields would be enough to understand the values. Would this work? How
    would I do this?

    Here's my current script (placed in the body) in pages 2-5 of my form
    questionnaire:
    <script language="Javascript">

    function PassedVars() {

    // capture previous answers from address bar AND
    // set the new value for the hidden field called PrevAnswers
    document.forms[0].PrevAnswers.value = (location.search.substring(1));

    document.forms[0].submit();
    }
    </script>

    <form name="Survey" action="/section3_feature-review/" method="get">
    <INPUT TYPE="hidden" NAME="PrevAnswers">
    ....more form elements for the new page
    <input name="SendOn" type="button" value="Continue to Section 3 of 5"
    onClick="PassedVars()" />
    </form>

    Thank you. Any input of direction is really appreciated. I'm on day 3
    of trying to do this!

    William
    williamroy, Nov 16, 2005
    #1
    1. Advertising

  2. > I've got a form that runs over 5 pages. I need the last page submit
    > button to post all of the answers at one time from the previous 5 pages
    > (to another server). I'd like to see the last page of the form post all
    > answers in clean ?= format as though all form elements were from one
    > page.


    If you have a server these pages are being served from you could create
    several hidden form elements by cycling through the GET query string
    (in PHP, for example, use foreach ($_GET as $var => $val) )

    If you don't you can parse the query string using something like the
    code at
    http://www.openjsan.org/doc/a/au/autarch/Form/Serializer/0.14/index.html
    then create the hidden elements using standard DOM methods.
    Joshie Surber, Nov 18, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    559
    Eliyahu Goldin
    May 31, 2005
  2. Rob R. Ainscough
    Replies:
    3
    Views:
    321
    Rob R. Ainscough
    Jun 14, 2005
  3. RadioSignal

    passing variables from .aspx.cs code pages to .aspx pages

    RadioSignal, Sep 12, 2005, in forum: ASP .Net Web Controls
    Replies:
    7
    Views:
    2,220
    Mirronelli
    Oct 22, 2005
  4. David E
    Replies:
    1
    Views:
    319
    Ray Costanzo [MVP]
    May 18, 2005
  5. Kioko --
    Replies:
    8
    Views:
    146
    Fabian Streitel
    Sep 8, 2009
Loading...

Share This Page