Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How to pass variables from 1 HTML page to another?  (Read 19083 times)

0 Members and 1 Guest are viewing this topic.

yattyyat

  • Guest
How to pass variables from 1 HTML page to another?
« on: April 03, 2004, 02:48:39 AM »
hi,
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!

Joleen

  • Guest
Re: How to pass variables from 1 HTML page to anot
« Reply #1 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..
<HTML>
<HEAD>
<TITLE>Welcome Page</Title>
<SCRIPT LANGUAGE="JavaScript">
//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
  document.write(newPage)
  //close writing stream
  document.close()
}
</SCRIPT>

<BODY>
<H1>Welcome!</H1>
<HR>
<FORM onSubmit="return false">
<P>
  Enter your name here: <INPUT TYPE="text" NAME="entry">
</P>
<INPUT TYPE="button" VALUE="New Page" onClick="rewritePage(this.form)">
</FORM>
</BODY>
</HTML>

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.
« Last Edit: April 05, 2004, 07:12:44 AM by Joleen »