function arguments
function arguments
hey guys im trying to make a select all checkbox script but i'm having problems with getting the argument and putting it into a variable all the code is below...but it is this code which seems to be the problem i believe...
- function toggleCheckboxes(group, element) {
group = $('input[@name='+ group +']');
var group_checkbox_count = $(group).length;
var group_checked_count = $(group:checked).length;
- .....
if anyone could tell me where i'm going wrong please...thank you
- <!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="/ajax/jquery/libary/jquery.js"></script>
<script>
function toggleCheckboxes(group, element) {
group = $('input[@name='+ group +']');
var group_checkbox_count = $(group).length;
var group_checked_count = $(group:checked).length;
if ($(element).text() == "")
{
if ($(group_checked_count) / $(group_checkbox_count) < 1) {
$(element).text() = "Select All";
}
else{
$(element).text() = "Deselect All";
}
}
}
toggleCheckboxes("sports", "selectbutton");
</script>
</head>
<body>
<form>
<span id="select button"></span>
Soccer: <input type="checkbox" name="sports" value="soccer" /><br />
Football: <input type="checkbox" name="sports" value="football" /><br />
Baseball: <input type="checkbox" name="sports" value="baseball" /><br />
Basketball: <input type="checkbox" name="sports" value="basketball" />
</form>
</body>
</html>