| | |
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™?
Views: 2725 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxexample ajaxjspservlets array autoplay blackjack browser captcha captchaformproblem cart child class close codes date debugger dependent developer disablefirebug dom editor element embed engine enter events explorer ext file firefox flash form forms frameworks game gears getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe java javascript javascripthelp2020 jquery jsf jsp jump libcurl maps margin marquee masterpage math media menu object onerror onmouseoutdivproblem onreadystatechange parent passing paypal pdf php player position post programming prototype rated redirect safari scale scriptlets scroll search security size software solutions sources star stars stretch synchronous toggle tweet unicode variables web webkit webservice window \n






