...

View Full Version : collecting and displaying data from a form



isabel ringing
02-26-2003, 07:12 PM
Hi
I am a novice at JavaScripting and need a script that will take info typed into a form and display it as plain text on another page. The idea is like this: a form might have fields for Name, Rank and Serial No. When filled out the data might be John Doe, Corporal, #123456. I would then like to be able to display this info on another page in a single line like John Doe Corporal #123456, hopefully separated by bullets.
I've seen this done on order forms using cookies, I assume. I have been able to set up a script that will store and display a cookie (using document.cookie.split) but I haven't figured how to retrieve multiple cookies and display them in the way stated above.
Any help is greatly appreciated.
Thanks

beetle
02-26-2003, 07:34 PM
You can use my Get Class (http://www.peterbailey.net/site/dev/jsclasses/) for that. Pretty easy, just download the file and include it into the page that the for submits to. Example...

form.htm
<html>
<head>
<title>Form</title>

</head>

<body>

<form action="process.htm" method="get">

<label for="Name">Name</label>
<input type="text" name="Name" />
<br />

<label for="Rank">Rank</label>
<input type="text" name="Rank" />
<br />

<label for="Serial_No">Serial Number</label>
<input type="text" name="Serial_No" />
<br />

<input type="submit" value="Submit" />

</form>

</body>
</html>And then process.htm
<html>
<head>
<title>Process</title>

<script type="text/javascript" src="js/get.class.js"></script>

</head>

<body>

<script type="text/javascript">

var g = new GetVars( 'Not Entered' );
document.write( g.assign('Name') + " &amp;#149; " + g.assign('Rank') + " &amp;#149; " + g.assign('Serial_No') );

</script>

</body>
</html>

isabel ringing
02-26-2003, 09:43 PM
Thanks beetle
I'll give ths a try!

poccil
02-26-2003, 09:46 PM
For purposes such as this, it's often better to use a server-side script, especially when the site needs to access a file in its servers, or if the user has JavaScript disabled or unsupported.

isabel ringing
02-26-2003, 11:05 PM
thanks to you both. the script from Beetle is most excellent. It works perfectly for what I want.
Thanks again.

jbetts1967
02-27-2003, 07:34 AM
Originally posted by beetle
You can use my Get Class (http://www.peterbailey.net/site/dev/jsclasses/) for that. Pretty easy, just download the file and include it into the page that the for submits to. Example...

form.htm
<html>
<head>
<title>Form</title>

</head>

<body>

<form action="process.htm" method="get">

<label for="Name">Name</label>
<input type="text" name="Name" />
<br />

<label for="Rank">Rank</label>
<input type="text" name="Rank" />
<br />

<label for="Serial_No">Serial Number</label>
<input type="text" name="Serial_No" />
<br />

<input type="submit" value="Submit" />

</form>

</body>
</html>And then process.htm
<html>
<head>
<title>Process</title>

<script type="text/javascript" src="js/get.class.js"></script>

</head>

<body>

<script type="text/javascript">

var g = new GetVars( 'Not Entered' );
document.write( g.assign('Name') + " &amp;#149; " + g.assign('Rank') + " &amp;#149; " + g.assign('Serial_No') );

</script>

</body>
</html>

this is good if you are using a form but i'm not using a form. i'm passing the variables using a command line (ie: document.write("<a href='goldbergphotos02.htm?" + gallerydir + "'><img src='../miscgoldberggraphics/goldbergnextpagebutton01.jpg' width='129' height='23' border='0' alt='Next Gallery'></a>");)

the example above is passing the varialbe "gallerydir" to "goldbergphotos02.htm" i want to add the variable "gallerynum" to the command line (ie: ("<a href='goldbergphotos02.htm?" + gallerydir + "&" + gallerynum"'>

this code is being passed to "goldbergphotos01.htm":
<a HREF="goldbergphotos01.htm?goldberggallery03"

i can add the following: <a HREF="goldbergphotos01.htm?goldberggallery03&gallerynum=1"

my question is how do you display in the recieving page:
<title>'Da Man' Bill 'The Annihilator' Goldberg - Gallery 1 Page 1</title>

so that the string Gallery 1 Page 1 is changed to Gallery "gallerynum" Page 1. "gallerynum" is determined by which button is pressed for a gallery.

thanks....



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum