Wrox Programmer Forums
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 23rd, 2009, 05:03 PM
Friend of Wrox
Join Date: Oct 2006
Posts: 112
Thanks: 12
Thanked 0 Times in 0 Posts
Default For loop

Hi to all...

in one of my pages i read data from my DB and display...
i have radio button which the user like select...

<input type="radio" id=group0 name=group0 maxlength=1 size=1 value=1>
<input type="radio" id=group1 name=group1 maxlength=1 size=1 value=1>
<input type="radio" id=group4 name=group4 maxlength=1 size=1 value=1>

i have the group ID in a loop do it all depends on how many i have in my DB...

my problem is when i send it to my next page with <form action=

all my other data that i got from my DB are displayed as the following since i useing the same id=name for them
100109, 100109, 100109, 100109, 100109
1, 1, 2, 1, 2
120, 130, 131, 132, 133
so I do ArrVarable = Split(variable, ", ") which creates an array andi know to which one they belong too...

with my group ID variables i trying to create a for loop to create a variable like my other one and then i can split it and i'll know which ones they will belong to...

For i = 0 To UBound(ArraySKU)
intIndexID = "group"+Request.form("i")
intIndexID = intIndexID & "," + "group"+Request.form("i")

my intIndexID is empty???

Hope i made it clear...

Thanking you in advance...
Old October 23rd, 2009, 08:59 PM
Friend of Wrox
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts

But a set of radio buttons with the SAME NAME (there is no reason to give them *any* ID...it's almost useless) will ONLY produce a *SINGLE* value!

That is, if you have:
<input type="radio" name="group1" value="1">
<input type="radio" name="group1" value="2">
<input type="radio" name="group1" value="3">
then in the ASP code you will do
group1 = Request("group1") 
and you will *ONLY* get a SINGLE value. You will *NEVER* get a comma-separated list. There is NEVER any reason to SPLIT anything.


You have the "group" in the WRONG PLACE in your ASP code:
For i = 0 TO UBound( ArraySKU )
    intIndexID = intIndexID & "," & Request("group" & i)
Is *that* what you are after???

But this makes NO SENSE! Why go to all that trouble to convert those separate radio button values into a list and then SPLIT the list to get an array????

Why not just DIRECTLY use
     Request("group" & i)
when you want the i'th radio button value???
The Following User Says Thank You to Old Pedant For This Useful Post:
RinoDM (October 26th, 2009)
Old October 26th, 2009, 09:06 AM
Friend of Wrox
Join Date: Oct 2006
Posts: 112
Thanks: 12
Thanked 0 Times in 0 Posts

the for loop worked perfectly, exactly what i need it to do...
thank you very much...
the reason why i wanted to do it this way is because from the pervious page i don't know how many rows will display...
so by doing the loop and then i
ArrayintIndexID = Split(intIndexID, ",")
creating an array putting them with the other right arrays..

Thx Rino

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop twice, then inside loop select nodes?? JohnBampton XSLT 2 March 9th, 2009 05:21 AM
Do Loop stealthdevil Access VBA 5 October 5th, 2006 01:22 PM
nested while loop doesn't loop hosefo81 PHP Databases 5 November 12th, 2003 08:46 AM
loop with out do monstermash Classic ASP Basics 3 July 15th, 2003 12:54 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.