Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Feb 2003
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    collecting and displaying data from a form

    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

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can use my Get Class for that. Pretty easy, just download the file and include it into the page that the for submits to. Example...

    form.htm
    Code:
    <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
    Code:
    <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>
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    New to the CF scene
    Join Date
    Feb 2003
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    form data printing on another page

    Thanks beetle
    I'll give ths a try!

  • #4
    New Coder
    Join Date
    Jul 2002
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: collecting and displaying data from a form

    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.

  • #5
    New to the CF scene
    Join Date
    Feb 2003
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thanks

    thanks to you both. the script from Beetle is most excellent. It works perfectly for what I want.
    Thanks again.

  • #6
    New to the CF scene
    Join Date
    Feb 2003
    Location
    Texas
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by beetle
    You can use my Get Class for that. Pretty easy, just download the file and include it into the page that the for submits to. Example...

    form.htm
    Code:
    <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
    Code:
    <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....


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •