| | |
Little confusion in multiple checkboxes
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Mar 2007
Posts: 22
Reputation:
Solved Threads: 0
Hello, i have a multiple checkbox that needs checking.
So i build some validation code through javascript.
I found some problem in setting the name of checkbox in a loop.
The loop should check three checkboxes.
Which are status1, status2, and status3.
You might want to see my code below.
It doesnt work.
Anybody please helps.....
Thanks.....
The code:
for(var i=1;i<=3;i++) {
if(document.form1.status+i.checked){
..........................
}else{
..........................
}
So i build some validation code through javascript.
I found some problem in setting the name of checkbox in a loop.
The loop should check three checkboxes.
Which are status1, status2, and status3.
You might want to see my code below.
It doesnt work.
Anybody please helps.....
Thanks.....
The code:
for(var i=1;i<=3;i++) {
if(document.form1.status+i.checked){
..........................
}else{
..........................
}
•
•
Join Date: May 2007
Posts: 30
Reputation:
Solved Threads: 2
try this...
for(i=1;i<=3;i++) {
tmp = "status" + i;
tmp1 = "document.form1." + tmp ;
alert(tmp1);
if(tmp1.checked){
..........................
}else{
..........................
}
This will work...
Cheers..
for(i=1;i<=3;i++) {
tmp = "status" + i;
tmp1 = "document.form1." + tmp ;
alert(tmp1);
if(tmp1.checked){
..........................
}else{
..........................
}
This will work...
Cheers..
Looking at my own code of Life and thinking what the hell is this....
------------------------------------
Middle East B2B Marketplace
Dubai Web Design
Dubai SEO
------------------------------------
Middle East B2B Marketplace
Dubai Web Design
Dubai SEO
•
•
Join Date: Mar 2007
Posts: 22
Reputation:
Solved Threads: 0
•
•
•
•
try this...
for(i=1;i<=3;i++) {
tmp = "status" + i;
tmp1 = "document.form1." + tmp ;
alert(tmp1);
if(tmp1.checked){
..........................
}else{
..........................
}
This will work...
Cheers..
But your code need some modification to make it work.
here is the modification:
for(i=1;i<=3;i++) {
tmp = "status" + i;
tmp1 = "document.form1." + tmp ;
tmp2 = tmp1+".checked";
if(tmp2){
..........................
}else{
..........................
}
Many thanks for the help azzu....
Last edited by enggars; May 10th, 2007 at 2:08 am.
Another way is shown oin the third post of my thread:
An array of arrays of of radio buttons
I gave all three checkboxes the same name. Then it was simple to do:
It seems to be the only way to do it with radio buttons.
An array of arrays of of radio buttons
I gave all three checkboxes the same name. Then it was simple to do:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
for(i=1;i<=3;i++) { tmp1 = document.form1.status[i].checked; alert(tmp1); if(tmp1){ .......................... } else{ .......................... }; };
Last edited by MidiMagic; May 10th, 2007 at 3:49 am.
Daylight-saving time uses more gasoline
![]() |
Similar Threads
- checkbox in datagrid (ASP.NET)
- Update Scoreboard - ASP (ASP)
- Paasing the values of Combo Box (PHP)
- How to Embed CheckList Box on HTML Page using Java Script (HTML and CSS)
- Fun with Forms (PHP)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: JS generated page 'save as' issues
- Next Thread: is there an anlternative to Snap Shots™?
| Thread Tools | Search this Thread |
ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate automatically beta box browser bug calendar captchaformproblem checkbox child class close column cookies createrange() css cursor debugger dependent disablefirebug dom download dropdown editor element embed engine error events explorer ext file form forms google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe images internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jump libcurl math media microsoft mimic object onmouseoutdivproblem onreadystatechange parent paypal pdf php player position post problem programming progressbar regex runtime scroll search security select session shopping size software sql text textarea unicode w3c web website window windowofwords windowsxp wysiwyg \n






