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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

For Next Loop in vbscript

Status
Not open for further replies.

Nugget1

Technical User
Apr 9, 2003
3
AU
I'm in a bit of a dilemma...please tell me what is the right thing to do.

when i create a 'for next loop' to create the number of labs
the user enters and a textfield beside each one for the user to enter the 'number' of the lab, i.e:
----FORM PAGE
<% dim varNumberLabs, varLineCounter

'assign variable to hold number submitted
varNumberLabs = Request.Form(&quot;LabNumbs&quot;)

'Print out contents of for loop
For varLineCounter = 1 to varNumberLabs '
Response.Write &quot;Lab: &quot;%>
<input type= &quot;Text&quot; name= &quot;labs&quot; size= &quot;5&quot;>
next
%>
<input type = hidden value = <%=Request.Form(&quot;LabNumbs&quot;)%> name = &quot;LabNumbs&quot;>
-------

------PAGE THAT REQUESTS FORM
<*
dim varLineCounter
'Print out contents of for loop
For varLineCounter = 1 to varNumberLabs
Response.Write &quot;Lab: &quot;
Response.Write Request.Form(&quot;Labs&quot;)
Response.Write &quot;Time from: &quot;
Response.Write Request.Form(&quot;TimeFrom&quot;)
Response.Write &quot;To: &quot;
Response.Write Request.Form (&quot;TimeTo&quot;)
Response.Write &quot;Students: &quot;
Response.Write varStudNumb
Response.Write &quot;<br/>&quot;
Next
%>
-------
...this does not assign different numbers to each lab so that i could, in the next page have:

'this is what we need to get
lab:1 <--number of lab filled in text box.
lab:2

'this is what i am getting
lab: 1,2 <--the for loop is going over and over again and i do not know where to put a break
lab: 1,2

can anyone please help me here?

thankyou! anticipating your reply!
 
on elittle thing
<input type = hidden value = &quot;<%=Request.Form(&quot;LabNumbs&quot;)%>&quot; name = &quot;LabNumbs&quot;>
needs the quotes around it unless this is a integer

second
seeing as you are sending the labs values as one named value they will concatinated and seperated by the ,

solution: either name them uniquely or split the labs form value at the , prior to the for next and loop through the split resulting array then.


it would be easy enough to name the with a unique name with a counter in the first loop concating the counter each increment to the labs name
labs1 etc. in all that would take out the need for the split then also as you will have your numbered labs resulting in the processing pages.

suggestion: next time you have a ASP question it's more appropriate and you'll get better faster answering in the ASP forum. Forum333

hope that helps out

_________________________________________________________
for the best results to your questions: FAQ333-2924
01001111 01101110 01110000 01101110 01110100
onpnt2.gif
[/sub]
 
Actually those quotes are only needed if the value contains punctuation such as spaces or something.

I think the bug might (partially?) be:

'Print out contents of for loop
For varLineCounter = 1 to varNumberLabs '
Response.Write &quot;Lab: &quot;%>
<input type= &quot;Text&quot; name= &quot;labs&quot; size= &quot;5&quot;><br>
<% next
%>
<input type = hidden value = <%=Request.Form(&quot;LabNumbs&quot;)%> name = &quot;LabNumbs&quot;>


And yep, try the ASP Forum next time.
 
Oops!

I should have added... &quot;the quotes should always be there anyway though&quot; (re. the value attribute assignment).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top