Forum Moderators: open

Message Too Old, No Replies

passing values of multiple text fields onto new page

         

bradr

6:37 pm on Jan 3, 2005 (gmt 0)

10+ Year Member



I apologize, I don't know javascript too well. I am trying to pass the values of about 10 textboxes from a form on one page, then have those values printed on a new page in pre-determined spots. I have been searching for a sample script for days to use as an example, without luck.

To get a feel for what I am trying to do please see the link below. It is a script that is doing the same thing except using popup alert boxes, that then print the response in the spot I want them. I would like to eliminate the pop-up alert, and use textboxes instead.
<No URLs, thanks. See TOS [WebmasterWorld.com]>

Thank you for the help!

[edited by: DrDoc at 2:47 am (utc) on Jan. 4, 2005]

adni18

8:37 pm on Jan 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try using this script:

questionaire.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>My Questionaire</TITLE>
</HEAD>
<BODY>
<form action="results.html" method="get">
<input value="John Doe" name="name"> Your name<br>
<input value="25" name="age"> Your age<br>
<input value="Salt Lake City" name="location"> Where you live<br>
etc...<br><br>
<input type="submit" value="Submit data!">
</form>
</BODY>
</HTML>

results.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Results to the Questionaire</TITLE>
</HEAD>
<script language=javascript type="text/javascript">
<!--
function callInput(key)
{
if(window.location.href.indexOf(key+'=')!=-1)
{
a=window.location.href.split("?")[1].split(key+"=")[1].split("&")[0];

/*The following will clean up the data*/
a=unescape(a);
a=a.replace(/\+/," ");

document.write(a);
}
else
{
alert("Not all fields were filled. Please re-enter them.");
history.go(-1);
}
}
//-->
</script>
<BODY>
You can call the values of the form anywhere you want! Like here:
<script language=javascript type="text/javascript">
<!--
callInput("age")
//-->
</script>, which is the value of age. Or
<script language=javascript type="text/javascript">
<!--
callInput("name")
//--></script>, which is your name.
</BODY>
</HTML>

bradr

9:34 pm on Jan 3, 2005 (gmt 0)

10+ Year Member



Thank you very much! Works out great! Only one thing. Is there any way to make it so the + signs don't come up with more then two works per value?

adni18

1:04 am on Jan 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here's the redoing of results.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Results to the Questionaire</TITLE>
</HEAD>
<script language=javascript type="text/javascript">
<!--
function callInput(key)
{
if(window.location.href.indexOf(key+'=')!=-1)
{
a=window.location.href.split("?")[1].split(key+"=")[1].split("&")[0];
/*The following will clean up the data*/
a=unescape(a);
a=a.replace(/\+/g," ");

document.write(a);
}
else
{
alert("Not all fields were filled. Please re-enter them.");
history.go(-1);
}
}
//-->
</script>
<BODY>
You can call the values of the form anywhere you want! Like here:
<script language=javascript type="text/javascript">
<!--
callInput("age")
//-->
</script>, which is the value of age. Or
<script language=javascript type="text/javascript">
<!--
callInput("name")
//--></script>, which is your name.
</BODY>
</HTML>

adni18

1:05 am on Jan 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Although you might want to know this is a much better job for a server-side language, like perl, asp, or php.