"wk6pack" wrote:
: I have a form with the following elements:
: first form
: <input type='text' name='addr1' value='1223 westward'>
: <input type='text' name='addr2' value='12 admirals rd'>
: <input type='text' name='addr3' value='90 Northward'>
: <input type='text' name='addr4' value='apt 12 34 Marine way'>
: <input type='text' name='addr5' value='2nd floor 900 Main St'>
:
: on submit the form will post them to the next form.
:
: second form
: <%
: while i < 5
: response.write("address " & i & " = " & request.form("addr" + i) &
: chr(13))
: i = i + 1
: wend
: %>
:
: Is the syntax correct to get the values? I tried it but I dont get any
: values for the request.
: If it is not the correct syntax, what should it be so I will be able to
see
: it when the first form posts it to the second one?
Will, I assume when you say 'second form' you mean page. When you're
working with forms you should show all relevant code since <form ...> is
usually the area of interest.
This is a workable solution.
[first.asp]
----------
<%@ Language=VBScript %>
<%
Option Explicit
Response.Buffer = True
%>
<html>
<head>
<script type="text/javascript">
function validate() {
var a = new Array(4);
for(i=0; i<5; i++) {
a[i] = document.getElementById("addr"+(i+1))
if(!a[i].value) {
alert(a[i].id + " cannot be blank");
a[i].focus();
return false;
}
}
document.form1.action="/lab/next.asp";
document.form1.submit();
return true;
}
</script>
<body>
<form id="form1" name="form1" method="post" onSubmit="return validate()">
<input id="addr1" type='text' name='addr1' value='1223 westward' /><br />
<input id="addr2" type='text' name='addr2' value='12 admirals rd' /><br />
<input id="addr3" type='text' name='addr3' value='90 Northward' /><br />
<input id="addr4" type='text' name='addr4' value='apt 1234 Marine way' /><br
/>
<input id="addr5" type='text' name='addr5' value='2nd floor 900 Main St'
/><br />
<input id="submit1" type="submit" name="submit1" value="submit" />
<input id="reset1" type="reset" name="reset1" value="reset" /><br />
</form>
</body>
</html>
[next.asp]
----------
<%@ Language=VBScript %>
<%
Option Explicit
Response.Buffer = True
dim info(5)
dim i
for i = 1 to 5
info(i)=Request.Form("addr" & i)
Response.Write("Address " & i & " = " & info(i) & "<br />" & vbCrLf)
next
%>
HTH...
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center -
http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation -
http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library -
http://msdn.microsoft.com/library/default.asp