Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > passing form variables between pages - not another searchstring question :)

Reply
Thread Tools

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

 
 
williamroy
Guest
Posts: n/a
 
      11-16-2005
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

 
Reply With Quote
 
 
 
 
Joshie Surber
Guest
Posts: n/a
 
      11-18-2005
> 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/aut....14/index.html
then create the hidden elements using standard DOM methods.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert a "normal" searchstring into regexp Kioko -- Ruby 8 09-08-2009 01:47 PM
passing variables from .aspx.cs code pages to .aspx pages RadioSignal ASP .Net Web Controls 7 10-21-2005 11:41 PM
Another basic question: How to call and show one Web Form from another Web Form? Rob R. Ainscough ASP .Net Web Controls 3 06-14-2005 03:56 PM
passing variables between pages lacombpcs@juno.com ASP .Net 2 05-31-2005 01:08 PM
Passing Variables Between ASP Pages using POST David E ASP General 1 05-18-2005 01:02 PM



Advertisments