Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hidden variables and passing data from one page to another

Status
Not open for further replies.

ColdFusionKing

Programmer
Dec 5, 2002
145
GB
Hello Everybody, I desperately need someone to help me. I am working on a Order Form, users can rent or buy desktops.
I have a form with a couple of text fields and drop downs common to users renting and ordering desktops. There are two submit
buttons "rent" and "buy". The user fills in the textboxes and select boxes and hits on "rent" or "buy". The form method is "post".
If the user hits the "rent" button, I want the user to be taken to another page "rent.html" passing all the form field values in hidden variables,
similarly when the user hits on "buy" button, I want the user to be taken to "buy.html" passsing all the form field values in hidden variables. I don't
know how to pass hidden variables to the action page and retreive their values in the action page. Can somebody please show me
how to do this. I am not using any server side language, only javascript and html. Is it possible to do this in client side language? Please can somebody show me how to do this

Here is my form

<form name=&quot;the_form&quot; method=&quot;post&quot;>
<table border=&quot;1&quot; height=&quot;223&quot;>
<tr>
<td class=&quot;lightblue&quot; colspan=&quot;2&quot; height=&quot;22&quot;>Order Date</td>
<td colspan=&quot;2&quot; height=&quot;22&quot;>
<input type=&quot;text&quot; name=&quot;orderDate&quot; value=&quot;&quot; size=&quot;56&quot;></td>
</tr>
<tr>
<td class=&quot;lightblue&quot; colspan=&quot;2&quot; height=&quot;22&quot;>Telephone Extension</td>
<td colspan=&quot;2&quot; height=&quot;22&quot;>
<input type=&quot;text&quot; name=&quot;telExtension&quot; value=&quot;&quot; size=&quot;56&quot;></td>
</tr>
<tr>
<td colspan=&quot;2&quot; height=&quot;22&quot;>
<select name=&quot;Category&quot;&quot;>
<option> Current_Affairs
<option> Finances
</select>
</td>
</tr>

<table width=&quot;200&quot; height=&quot;30&quot; border=&quot;0&quot; align=&quot;center&quot;>
<tr>
<td width=&quot;100&quot;><input type=&quot;submit&quot; name=&quot;rentsubmit&quot; value=&quot;rent&quot;></td>
<td width=&quot;100&quot;><input type=&quot;submit&quot; name=&quot;buysubmit&quot; value=&quot;buy&quot;></td>
</tr>
</table>
</form>

Many Thanks
Allan
 
I don't know that it can't be done w/o a server side language. But.... if you use asp it's as simple as this:

<%Request.Form(&quot;blah&quot;);%>
<INPUT TYPE=HIDDEN NAME=blah VALUE=<%=blah%>>

this pulls the form variable blah from page 1 and puts it in a hidden variable on page 2

-kaht
 
There are two ways to pass data using javascript
1) use the url with window.location.search
you can pull values from the address bar
e.g. /index.html?name=Ted&meth=Rent

2) use the stored values in the opener,
here's 2 pages the new window pulls values from
the opener.

First Page #-----#
Code:
<html><head><script language=&quot;JavaScript&quot;>
function opwin(url) {
nwwin = window.open(url);
}
</script></head><body>
<form name=&quot;orig&quot;>
<b>Yes I want to Rent 100</b><br>
<input type=&quot;text&quot; name=&quot;fname&quot; size=&quot;15&quot;><br>
<input type=&quot;text&quot; name=&quot;lname&quot; size=&quot;15&quot;><br>
<input type=&quot;text&quot; name=&quot;meth&quot; size=&quot;15&quot;><br>
<br><b>All with WIN3.11</b><br>
<input type=&quot;button&quot; value=&quot;Rent&quot; onClick=&quot;opwin('rent.html');&quot;>
<br><input type=&quot;button&quot; value=&quot; Buy &quot; onClick=&quot;opwin('buy.html');&quot;>
</form></body></html>

rent.html #-----#
Code:
<html><head><script language=&quot;JavaScript&quot;>
function gtvals() {
d = document.nwform;
o = opener.document.orig;
d.fname.value = o.fname.value;
d.lname.value = o.lname.value;
d.meth.value = o.meth.value;}
</script></head><body onLoad=&quot;gtvals();&quot;>
<form name=&quot;nwform&quot;>
<b>Make Mine a Pentium SuperDooper</b><br>
<input type=&quot;text&quot; name=&quot;fname&quot; size=&quot;15&quot;><br>
<input type=&quot;text&quot; name=&quot;lname&quot; size=&quot;15&quot;><br>
<input type=&quot;text&quot; name=&quot;meth&quot; size=&quot;15&quot;><br>
<br><b>With a 400Gig Drive</b></form>
</body></html>

2b||!2b
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top