Home / Internet & Networking / Web design / How to pass variables from 1 HTML page to another?
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] - (Bottom) Print
Author Topic: How to pass variables from 1 HTML page to another?  (Read 3975 times)
yattyyat
Guest
« 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!
IP logged
Joleen
Guest
« 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 » IP logged
Pages: [1] - (Top) Print 
Home / Internet & Networking / Web design / How to pass variables from 1 HTML page to another? « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.1 seconds with 18 queries.