Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Checking and Unchecking Checkboxes in CGI.pm

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 CGI.pm

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:/ +/www.w3.org/TR/html4/loose.dtd"> <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>
Michael

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://633302]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2016-12-04 13:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (65 votes). Check out past polls.