Internet & Networking > Web design

How to pass variables from 1 HTML page to another?

(1/1)

yattyyat:
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:
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.

Navigation

[0] Message Index

Go to full version