473,382 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

how to retrieve elements on next form

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
10 1530
> 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
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
"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
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
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
"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
"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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: forums_mp | last post by:
I've got an STL class (see below) with two functions to store and retrieve data - msg structs. The "Store" function when called will copy the received message (depending on which message) into...
1
by: Bryan | last post by:
Hello: I need to retrieve the value of a textbox control in a asp.net datagrid using Javascript. Can anybody help out. I believe the control clientID needs to be passed client side so the...
5
by: Dani | last post by:
Hello everybody, I have some code that disables form elements on body load, but I notice when I hit the "back" button, I need to re-enable the form elements (that is done by clicking on a radial...
0
by: Pat Patterson | last post by:
I'm having serious issues with a page I'm developing. I just need some simple help, and was hoping someone might be able to help me out in here. I have a form, that consists of 3 pages of...
5
by: bobdydd | last post by:
Hi Everybody I have an Access database that passes a Parameter to a web page something like this. http://localhost/index.htm?paramName=1234-54321 I want to be able to retrieve the parameter...
3
by: Kees de Winter | last post by:
Hi, If I have a TextBox place inside a content placeholder then at runtime the TextBox's name changes to ctl00_ContentPlaceHolder1_tbCity. What is the best way to get the value of the TextBox...
6
by: ashok.dhananjeyan | last post by:
Hi, Actually , I wrote one javascript to retrieve the name of the form in one particular page. what i did in this page is, <script> function checkbutton() {
13
by: kev | last post by:
Hi all, I have created a database for equipments. I have a form to register the equipment meaning filling in all the particulars (ID, serial, type, location etc). I have two buttons at the end...
3
by: David | last post by:
Hi, I have some code in my form as follows, to display 1 to 20 additional sets of fields to enter guest information. I am not sure how to retrieve these guests info so that I can post the info...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.