Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

request.form help

Status
Not open for further replies.

dcarbone

Programmer
Aug 22, 2003
29
CA
i have a series of about 600 text boxes that i need to pass to another asp page and they are named using a loop. ie

do while not rst.eof
<input type=text name=&quot;<%&quot;name&quot; & loop_counter %>&quot;>
rst.movenext
loop

the exact number of boxes is not known and depends on user parameters.

how would i use request.form on the following page to get the data from these input boxes.

this code does not work

for indx = 1 to loop_counter
val = request.form(&quot;name&quot; & indx)
next

 
dcarbone;

dim myarray

for indx = 1 to loop_counter
myarray(indx)= request.form(&quot;name&quot; & indx)
next


fengshui_1998
 
Are you passing Loop_Counter in a hidden form field (after it reaches it's highest point)? Then on the other form:
Loop_Counter = request.form(&quot;Loop_Counter&quot;)

By the way this code is only going to change the value of the variable val Loop_Counter number of times and eventually leave you with the final (highest) Loop_Counter.
for indx = 1 to loop_counter
val = request.form(&quot;name&quot; & indx)
next
 
here it is a simpler way.
Name all your input boxes the same and then on the server you knw how many you have easyly.

do while not rst.eof
<input type=text name=&quot;myText&quot; value=...>
rst.movenext
loop


and on the server side you will now have an Request.Form(&quot;myText&quot;) as an array.

Now you can use

for each textval in Request.Form(&quot;myText&quot;)
'now text val contains each value.
next

or the clearer way
for i=0 to Request.Form(&quot;myText&quot;).Count-1 '0 index based array
mytext=Request.Form(&quot;myText&quot;).(i)
next

This should fix your naming problem. You knw how many items you have with:
nrItems=Request.Form(&quot;myText&quot;).Count

________
George, M
 
You can use the forms collection on the page your text boxes are submitted to like so

for each key in Request.Form
Response.Write key & &quot; &quot; & Request.Form(key)
next

the key is the name of the control(i.e. textbox, button etc)
Request.form(key) would be the value

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top