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

W

williamroy

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
 
J

Joshie Surber

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top