For Loops and Text Boxes

Results 1 to 3 of 3

Thread: For Loops and Text Boxes

  1. #1
    Join Date
    Dec 1969

    Default For Loops and Text Boxes

    Hello friends,<BR><BR>I have a forms page where the text boxes is generated by using a for loop, as an example see below Page1:<BR><BR>Page 1:<BR>---------<BR>&#060;%<BR>for i=0 to 4<BR>%&#062;<BR>&#060;input type="text" name="part_number&#060;%=i%&#062;" &#062;<BR>&#060;% Next %&#062;<BR><BR>Like this i can get as many text boxes as i would like to. Then I would like to view the input value in the text field of page1 in the text boxes of page two . please see the example below:<BR>Page 2:<BR>--------<BR>&#060;%<BR><BR>part_number1=request.form("part _number1")<BR>part_number2=request.form("part_numb er2")<BR>part_number3=request.form("part_number3") <BR>part_number4=request.form("part_number4")<BR>p art_number5=request.form("part_number5")<BR><BR>%& #062;<BR>&#060;%<BR>for i=1 to 5<BR>%&#062;<BR>&#060;%<BR><BR>part_number="part_n umber" & i<BR><BR>%&#062;<BR>&#060;input name="part_number&#060;%=i%&#062;" value="&#060;% response.write(part_number)%&#062;"&#062;<BR><BR>& #060;%<BR>Next<BR>%&#062;<BR><BR><BR>But rather than getting the value of part_number which i had input in page 1 I simply get the values as<BR>"part_number1"<BR>"part_number2"<BR>"part_nu mber3"<BR>"part_number4"<BR>"part_number5"<BR><BR> Can anyone please give me a solution of how can i get the values in the text boxes of page two.<BR>Note: I am using a for loop because I may also have as many as 50 text boxes . Bill Willkinson r u online ?<BR><BR>Thank You & Best Regards<BR>Nilabdhi<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: For Loops and Text Boxes

    instead of simply labeling your textboxes with the counter value (i) use a combination of a text name and the counter value:<BR><BR>for i = 0 to iMax<BR>response.write "&#060;input type=text name=""text" & i & """&#062;<BR>next<BR><BR>then, in the retieving page:<BR><BR>for i = 0 to iMax<BR>sVal(i) = request.form("text" & i)<BR>next<BR><BR>in case you forgot (or don&#039;t know :) the values from a returned form can also be referred to by their<BR><BR>for i = 1 to request.form.count<BR>request.form(i)<BR>next<BR>< BR>will list all returned form values. when you try and label a form element with simply an integer you will (as you noticed) run into problems trying to retieve the value using the typical method.<BR>hope this sheds some light on the matter<BR><BR>justin

  3. #3
    Join Date
    Dec 1969

    Default And please, next time...

    ...ask this in the ASP Q&A forum, not in the advanced forum. See the rules at the top of the page about what constitutes "advanced."<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts