Setting the value of a hidden field with a function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 
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.
 
You guessed right about the client and your suggestion worked perfectly!
Thank You!
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top