I have a lot of checkboxes, with the same id="cbna", but when i submit the form , the javascript code should check If atleat one checkbox is checked, if not an alert should pop up. if it is checked the the value stored in site the checkbox should execute along with the details of a text area. I have tried to do the same but in vain.
<script>
function checkCheckBoxes(form1)
{
if (document.form1.checked==true)
{
function OpenWindow(info)
{
window.open(info);
}
}
else
{
alert ('You didn\'t choose any of the checkboxes!');
return false;
}
}
</script>
<form name="form1" id="form1" method="post" action="" >
<p>
<input type="checkbox" name="checkbox" onclick="if(this.checked)OpenWindow(this.value)}" value="www.something.com 1" />
google<br />
<input type="checkbox" name="checkbox" onclick="if(this.checked){OpenWindow(this.value)}" value="www.something.com 2" />
apple<br />
<input type="checkbox" name="checkbox" onclick="if(this.checked){OpenWindow(this.value)}" value="www.something.com 3" />
ibm<br />
<input type="checkbox" name="checkbox" onclick="if(this.checked){OpenWindow(this.value)}" value="www.something.com 4" />
nageo<br />
<textarea cols="100" rows="22" id="descp" >
hello wats up!
</textarea>
<input onclick="checkCheckBoxes(form1)" value="create forms" type="button">
</form>
</body>
</html>