I am trying to make a JS script (utilizing Jquery) to make certain tablerows appear or disappear based upon whether a checkbox is checked or unchecked. I was experimenting with buttons to make these tablerows appear/disappear and was successful, but now I want to make it work for checkboxes. This is my first JS code I've tried to write, so please excuse the noob in me.
I did some checking, and apparently the cat function is not even called... hmm
Code:
$(document).ready(function(){
function cat(cat) {
if (getElementById("#" + cat + "\"").checked) {
$("[cat='" + cat + "']").addClass("show");
$("[cat='" + cat + "']").removeClass("hide");
} else {
$("[cat='" + cat + "']").addClass("hide");
$("[cat='" + cat + "']").removeClass("show");
}
}
$("#Art").click(cat("Art"); alert("sometext"););
});
Code:
<form>
Categories:<br />
<input type="checkbox" id="Art" /> Art<br />
<input type="checkbox" id="Academic" /> Academic<br />
<input type="checkbox" id="Environment" /> Environment<br />
<input type="checkbox" id="Sports" /> Sports<br />
<br />
Schools:<br />
<input type="checkbox" id="5C" /> Five-College<br />
<input type="checkbox" id="CM" /> Claremont McKenna<br />
<input type="checkbox" id="CM" /> Harvey Mudd<br />
<input type="checkbox" id="PZ" /> Pitzer<br />
<input type="checkbox" id="PO" /> Pomona<br />
<input type="checkbox" id="SC" /> Scripps<br /><br />
</form>
Any help would be greatly appreciated! I have done a lot of Googleing to no avail.
|