Computer Hope

Internet & Networking => Web design => Topic started by: yattyyat on April 03, 2004, 02:48:39 AM

Title: How to pass variables from 1 HTML page to another?
Post by: yattyyat on April 03, 2004, 02:48:39 AM
i'm trying to create a HTML page that allows user to fill in some fields in a form. once the user clicks the Submit button, the browser will POST the entered fields to another HTML page for display.

is this possible to be done in HTML without having to create a script in the web server (or is it application server)? do i have to use JSP, ASP or others instead of HTML given the simplicity of this task? if so, how to do it? thanks!
Title: Re: How to pass variables from 1 HTML page to anot
Post by: Joleen on April 05, 2004, 07:05:26 AM
Most ISPs shy away from allowing users to put up asp/jsp.  I'd try JavaScript.  You could use something like..
<TITLE>Welcome Page</Title>
//Create custom page and replace current document with it
function rewritePage(form){
  //accuulate HTML content for new page
  var newPage = "<HTML>\n<HEAD>\n<TITLE>Page for "
  newPage += form.entry.value
  newPage += "</TITLE>\n</HEAD>\n<BODY BGCOLOR='blue'>\n"
  newPage += "<H1>Hello, " + form.entry.value + "!</H1>\n"
  newPage += "</BODY>\n</HTML>"
  //write it in one blast
  //close writing stream

<FORM onSubmit="return false">
  Enter your name here: <INPUT TYPE="text" NAME="entry">
<INPUT TYPE="button" VALUE="New Page" onClick="rewritePage(this.form)">

Lots of other examples you could try.  You could also go the cookie route but I suggest staying away from that one.

Edited for pre-coffee typos.