p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 23rd, 2009, 06:03 PM
Authorized User
Points: 422, Level: 7
Points: 422, Level: 7 Points: 422, Level: 7 Points: 422, Level: 7
Activity: 20%
Activity: 20% Activity: 20% Activity: 20%
 
Join Date: Oct 2006
Location: , , .
Posts: 91
Thanks: 8
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")
next

my intIndexID is empty???

Hope i made it clear...

Thanking you in advance...
Rino
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old October 23rd, 2009, 09:59 PM
Friend of Wrox
Points: 4,805, Level: 29
Points: 4,805, Level: 29 Points: 4,805, Level: 29 Points: 4,805, Level: 29
Activity: 50%
Activity: 50% Activity: 50% Activity: 50%
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,323
Thanks: 3
Thanked 70 Times in 69 Posts
Default

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???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
The Following User Says Thank You to Old Pedant For This Useful Post:
RinoDM (October 26th, 2009)
  #3 (permalink)  
Old October 26th, 2009, 10:06 AM
Authorized User
Points: 422, Level: 7
Points: 422, Level: 7 Points: 422, Level: 7 Points: 422, Level: 7
Activity: 20%
Activity: 20% Activity: 20% Activity: 20%
 
Join Date: Oct 2006
Location: , , .
Posts: 91
Thanks: 8
Thanked 0 Times in 0 Posts
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop twice, then inside loop select nodes?? JohnBampton XSLT 2 March 9th, 2009 06:21 AM
Do....Loop While loop junedali10 BOOK: VBScript Programmer's Reference, 1st, 2nd, and 3rd editions 1 February 4th, 2008 03:51 PM
Do Loop stealthdevil Access VBA 5 October 5th, 2006 02: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 01:54 PM



All times are GMT -4. The time now is 06:47 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc