HTML JQuery Ref Passed to Function
this is my code. I want the alert("SHOW ME!!") to show but it works all
the way up until that point, so the line before is causing the problem.
Idk how to fix it. Could it be how I'm passing reference to the function?
Thank you!!!
<!DOCTYPE html>
<html>
<head>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("#Sub1").click(function(){
readIngred($("#ingredForm"));
});
});
</script>
<script type="text/javascript">
function readIngred(form)
{
var checked;
var checkedBoxes;
//Create an array of checked radio buttons
checked = form.elements["checkSet"];
alert("SHOW ME!!!");
checkedBoxes = new Array(checked.length);
for(var i = 0, j = 0; i < radios.length; i++, j++)
{
if(checked[i].checked == true)
{
checkedBoxes[j] = checked[i];
}
else
j--;
}
var c = 0;
while(checkedBoxes[c] !== null)
{
c++;
}
alert("You picked " + c + " ingredients");
}
</script>
</head>
<body>
<form id="ingredForm">
<ul style="list-style-type:none;">
<li><input type="checkbox" name="checkSet" value="Pep">Pep</li>
<li><input type="checkbox" name="checkSet" value="Mush">Mush</li>
<li><input type="checkbox" name="checkSet" value="Olive">Olive</li>
<li><input type="checkbox" name="checkSet" value="Cheese">Cheese</li>
</ul>
<input type="submit" name="Submit_Button" id="Sub1" value="Send">
</form>
</body>
No comments:
Post a Comment