|
-
Oct 7th, 2001, 11:49 PM
#1
Thread Starter
PowerPoster
URGENT JavaScript problem...
Hey all.
I have an .asp page in which a form is created by Server-Side VBScript.
In the form I have a set of checkboxes named:
checkbox0
checkbox1
.
.
.
checkboxN
(N can range from about 4 to 10 depending on the creation script)
I need to use JavaScript to verify the form input.
How do I refer to these checkboxes in a for loop?
Is that possible?
eg:
for (i = 0; i < N; i++) {
window.alert(document.form.<B>(checkbox + i)</B>.value)
}
This is a big problem for me right now...
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
Oct 7th, 2001, 11:58 PM
#2
try this:
Code:
for (i = 0; i < N; i++) {
eval("window.alert(document.form.checkbox" + i + ".value) ;");
}
not completely sure, but I think it will work.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Oct 8th, 2001, 12:18 AM
#3
Thread Starter
PowerPoster
Excellent!
Cheers dude, you saved me!
I just couldn't figure the syntax. I never would've got it I don't think. I've been fiddling for over an hour now...
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
Oct 8th, 2001, 12:20 AM
#4
No problem.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Oct 8th, 2001, 12:45 AM
#5
Thread Starter
PowerPoster
Can I be a pest?
I have tried the same method with radio buttons, but to no avail.
The radio buttons are all called 'radio' but with different values, obviously...
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
Oct 8th, 2001, 02:08 AM
#6
Hyperactive Member
If you had N radio buttons, U have to loop thro' them and find which of them is checked.
for (i = 0; i < N; i++)
{
if (document.form.radio[i].checked == true)
alert(document.form.radio[i].value);
}
- Jemima.
-
Oct 8th, 2001, 02:25 AM
#7
Thread Starter
PowerPoster
Thanks Jem,
I'd forgotten all about the radio[i] property...
It's been awhile..
Hey, not meaning to be rude, but are you following me?
You seem to be the one solving all my problems.
Thanks!
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
Oct 8th, 2001, 03:04 AM
#8
Hyperactive Member
for (i = 0; i < N; i++) {
window.alert(document.form.<B>(checkbox + i)</B>.value)
}
just a quick point rjlohan, you can't but html tags in an alert box!
-
Oct 8th, 2001, 03:45 AM
#9
Hyperactive Member
oh boy! Did he mean
for (i = 0; i < N; i++) {
window.alert(document.form. (checkbox + i).value)
} ?
- Jemima.
Last edited by JemimaChadwick; Oct 8th, 2001 at 03:50 AM.
-
Oct 8th, 2001, 03:45 AM
#10
Hyperactive Member
Jus a Mess!!! Pardon.
- Jemima.
-
Oct 8th, 2001, 05:27 PM
#11
Thread Starter
PowerPoster
Yeah, I did Jem, sorry Bob, I'm not that that out of touch.
I just used the wrong bracket when trying to highlight something for my post...
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|