|
|
 |
| Javascript General Javascript discussions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Javascript section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

October 23rd, 2009, 06:03 PM
|
|
Authorized User
|
|
Join Date: Oct 2006
Location: , , .
Posts: 91
Thanks: 8
Thanked 0 Times in 0 Posts
|
|
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")
next
my intIndexID is empty???
Hope i made it clear...
Thanking you in advance...
Rino
|

October 23rd, 2009, 09:59 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,323
Thanks: 3
Thanked 70 Times in 69 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:
Code:
<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
Code:
<%
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.
OH WAIT! I SEE IT!
You have the "group" in the WRONG PLACE in your ASP code:
Code:
<%
For i = 0 TO UBound( ArraySKU )
intIndexID = intIndexID & "," & Request("group" & i)
Next
%>
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
Code:
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:
|
|

October 26th, 2009, 10:06 AM
|
|
Authorized User
|
|
Join Date: Oct 2006
Location: , , .
Posts: 91
Thanks: 8
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
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |