Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Checking and Unchecking Checkboxes in

by misc (Pilgrim)
on Aug 17, 2007 at 14:21 UTC ( #633302=note: print w/replies, xml ) Need Help??

in reply to Checking and Unchecking Checkboxes in

Your question is really not perl related, however, here is some javascript which implements what you seem to ask for.

I've tested in Konqueror, Firefox and IE.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http:/ +/"> <html> <head> <title></title> <meta name="GENERATOR" content="VIM"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script language="JavaScript"> var twofastest; var checkboxes=[]; function initVars(){ if ( twofastest ) return; twofastest = document.getElementById('twofastest'); var cb = document.getElementsByName('progname'); var b = 0; for (var a=0; a<cb.length; a++ ){ if ( cb[a] != twofastest ){ checkboxes[b] = cb[a]; b++; } } } function checkBoxClick(){ initVars(); var anyboxchecked = false; for (var a=0; a<checkboxes.length; a++ ){ if ( checkboxes[a].checked ) anyboxchecked = true; } twofastest.disabled = anyboxchecked; } function twofastestClick(){ initVars(); for (var a=0; a<checkboxes.length; a++ ){ if ( twofastest.checked ) checkboxes[a].checked = false; checkboxes[a].disabled = twofastest.checked; } } </script> </head> <body> <form action=""> <input type="checkbox" name="progname" value="2fastest" id="twofas +test" onClick="twofastestClick()">2 Fastest<br/> <input type="checkbox" name="progname" value="mitra" onClick="checkBoxClick()" />Mitra <br/> <input type="checkbox" name="progname" value="space" onClick="checkBoxClick()" />Space <br/> <input type="checkbox" name="progname" value="meme" onClick="checkBoxClick()" />Meme <br/> </form> </body> </html>

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://633302]
[marto]: good morning all
[prospect]: Good morning ! More Perl learning today, Man that subroutines chapter is tough.
[marto]: tutorials-> Subroutines may be of interest

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2017-07-24 07:54 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (348 votes). Check out past polls.