Setting the value of a hidden field with a function

M

Mary B.

Is it possible to set the value of a hidden field using the result of a
functon? I'm trying to save a random number that I generate with a function
(an order number) with the rest of the data fields in my form.
 
M

MikeR

Mary - here's one way, if you can use asp
order.asp
<%
Dim Ordernumber
Ordernumber = 00002222
%>
<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>
Ordernumber = <%=Ordernumber%> <p>
<form method="POST" action="orderfill.asp">
Enter the item you want to order
<input type="Hidden" name="ordno" value=<%=Ordernumber%> size="20">
<input type="text" name="T1" size="20">
<input type="submit" value="Submit" name="B1">
<input type="reset" value="Reset" name="B2"></p>
</form>

</body>

</html>

orderfill.asp
<%
response.buffer = true
ornum = request("ordno")
%>
<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 2</title>
</head>

<body>
Hello<br>
Your ordernumber is: <%=ornum%>
</body>

</html>

MikeR
 
M

MD Websunlimited

Hi Mary,

You don't say whether of not you wish to accomplish this at the server or client.

If the client then

<input type="hidden" name="myfield" >

<input type="submit" onclick="this.form.myfield.value = myfunction(myparam); return true;" >

When the visitor clicks the submit button the hidden field myfield will be set with the returned value of the functon myfunction.
 
M

Mary B.

You guessed right about the client and your suggestion worked perfectly!
Thank You!
 
M

Mary B.

Thanks for your help!

MikeR said:
Mary - here's one way, if you can use asp
order.asp
<%
Dim Ordernumber
Ordernumber = 00002222
%>
<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>
Ordernumber = <%=Ordernumber%> <p>
<form method="POST" action="orderfill.asp">
Enter the item you want to order
<input type="Hidden" name="ordno" value=<%=Ordernumber%> size="20">
<input type="text" name="T1" size="20">
<input type="submit" value="Submit" name="B1">
<input type="reset" value="Reset" name="B2"></p>
</form>

</body>

</html>

orderfill.asp
<%
response.buffer = true
ornum = request("ordno")
%>
<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 2</title>
</head>

<body>
Hello<br>
Your ordernumber is: <%=ornum%>
</body>

</html>

MikeR
 
Top