By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,107 Members | 1,607 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,107 IT Pros & Developers. It's quick & easy.

how to retrieve elements on next form

P: n/a
Hi,

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?

thanks,
Will
Jul 19 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
> while i < 5

With this statement, your 5th address will never be written. Change it to...

while i < 6
response.write("address " & i & " = " & request.form("addr" + i) &
chr(13))
Change the above line to...
response.write("address " & i & " = " & request.form("addr" & i) & chr(13))

(notice the "&" replacing the "+")

Randy

"wk6pack" <wk***@sd61.bc.ca> wrote in message
news:Ol**************@TK2MSFTNGP10.phx.gbl... Hi,

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
<% 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?

thanks,
Will

Jul 19 '05 #2

P: n/a
Hi Randy,

That didnt work. I get nothing coming back.

Will
"Randy Rahbar" <rvrahbar@_JUNKETY_JUNK_hotmail.com> wrote in message
news:Of**************@TK2MSFTNGP09.phx.gbl...
while i < 5
With this statement, your 5th address will never be written. Change it

to...
while i < 6
response.write("address " & i & " = " & request.form("addr" + i) &
chr(13))
Change the above line to...
response.write("address " & i & " = " & request.form("addr" & i) &

chr(13))
(notice the "&" replacing the "+")

Randy

"wk6pack" <wk***@sd61.bc.ca> wrote in message
news:Ol**************@TK2MSFTNGP10.phx.gbl...
Hi,

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
<%

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?

thanks,
Will


Jul 19 '05 #3

P: n/a
"wk6pack" <wk***@sd61.bc.ca> wrote in message
news:Ol**************@TK2MSFTNGP10.phx.gbl...
Hi,

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?


This should do what you want:

<%
i = 1
while i < 5
frmStr = "addr" & i
Response.Write("address " & i & " = " & Request.Form(frmStr) & "<br>")
i = i + 1
wend
%>
Note that another option might be to interate through the Form collection,
but it will also include the submit button, and any other form inputs
<%:
For Each item in Request.Form
Response.Write(item & " = " & Request.Form(item) & "<br>")
Next
%>

Regards,
Peter Foti
Jul 19 '05 #4

P: n/a
Oops, I forgot 2 things....
1. Set i to 1 before the loop
2. Do while i < 6 instead of 5.

Thus, first 3 lines should be:
<%
i = 1
while i < 6

The rest remains the same.
Regards,
Peter
"Peter Foti" <pe***@Idontwantnostinkingemailfromyou.com> wrote in message
news:10*************@corp.supernews.com...
"wk6pack" <wk***@sd61.bc.ca> wrote in message
news:Ol**************@TK2MSFTNGP10.phx.gbl...
Hi,

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?


This should do what you want:

<%
i = 1
while i < 5
frmStr = "addr" & i
Response.Write("address " & i & " = " & Request.Form(frmStr) & "<br>")
i = i + 1
wend
%>
Note that another option might be to interate through the Form collection,
but it will also include the submit button, and any other form inputs
<%:
For Each item in Request.Form
Response.Write(item & " = " & Request.Form(item) & "<br>")
Next
%>

Regards,
Peter Foti

Jul 19 '05 #5

P: n/a
My understanding is that

"addr" & i

would have a space in the string, as i would have a positive or negative
indicator. That is, if i was 1 then it's value as a string would be " 1"
because of the missing + sign.

If you just want to pass your form data along. Try something like....

Dim field
for each field in Request.Form
Response.Write "<input type=hidden name=""" & field & """ value=""" &
Request.Form(field) & """>"
next
"Randy Rahbar" <rvrahbar@_JUNKETY_JUNK_hotmail.com> wrote in message
news:Of**************@TK2MSFTNGP09.phx.gbl...
while i < 5
With this statement, your 5th address will never be written. Change it

to...
while i < 6
response.write("address " & i & " = " & request.form("addr" + i) &
chr(13))
Change the above line to...
response.write("address " & i & " = " & request.form("addr" & i) &

chr(13))
(notice the "&" replacing the "+")

Randy

"wk6pack" <wk***@sd61.bc.ca> wrote in message
news:Ol**************@TK2MSFTNGP10.phx.gbl...
Hi,

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
<%

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?

thanks,
Will


Jul 19 '05 #6

P: n/a
"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
Jul 19 '05 #7

P: n/a
"Tom B" <sh*****@NOSPAMhotmail.com> wrote in message
news:O%****************@TK2MSFTNGP10.phx.gbl...
My understanding is that

"addr" & i

would have a space in the string, as i would have a positive or negative
indicator. That is, if i was 1 then it's value as a string would be " 1"
because of the missing + sign.


No, you are incorrect. The string value of 1 is "1".

Regards,
Peter Foti
Jul 19 '05 #8

P: n/a
Thanks Peter, that works great now.
Will

"Peter Foti" <pe***@Idontwantnostinkingemailfromyou.com> wrote in message
news:10*************@corp.supernews.com...
Oops, I forgot 2 things....
1. Set i to 1 before the loop
2. Do while i < 6 instead of 5.

Thus, first 3 lines should be:
<%
i = 1
while i < 6

The rest remains the same.
Regards,
Peter
"Peter Foti" <pe***@Idontwantnostinkingemailfromyou.com> wrote in message
news:10*************@corp.supernews.com...
"wk6pack" <wk***@sd61.bc.ca> wrote in message
news:Ol**************@TK2MSFTNGP10.phx.gbl...
Hi,

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?


This should do what you want:

<%
i = 1
while i < 5
frmStr = "addr" & i
Response.Write("address " & i & " = " & Request.Form(frmStr) & "<br>") i = i + 1
wend
%>
Note that another option might be to interate through the Form collection, but it will also include the submit button, and any other form inputs
<%:
For Each item in Request.Form
Response.Write(item & " = " & Request.Form(item) & "<br>")
Next
%>

Regards,
Peter Foti


Jul 19 '05 #9

P: n/a
Got it. thanks for you reply.
Will
"Roland Hall" <nobody@nowhere> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
"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

Jul 19 '05 #10

P: n/a
I was missing a couple of things. Thanks for you reply.

Will
"Randy Rahbar" <rvrahbar@_JUNKETY_JUNK_hotmail.com> wrote in message
news:Of**************@TK2MSFTNGP09.phx.gbl...
while i < 5
With this statement, your 5th address will never be written. Change it

to...
while i < 6
response.write("address " & i & " = " & request.form("addr" + i) &
chr(13))
Change the above line to...
response.write("address " & i & " = " & request.form("addr" & i) &

chr(13))
(notice the "&" replacing the "+")

Randy

"wk6pack" <wk***@sd61.bc.ca> wrote in message
news:Ol**************@TK2MSFTNGP10.phx.gbl...
Hi,

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
<%

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?

thanks,
Will


Jul 19 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.