mardi 3 février 2015

Script for Select All checkboxes not working on WordPress page

I'm trying to create checkboxes with a Select All checkbox in a normal WordPress page using a Text block.


Here's my code:



<script type="text/javascript">
alert('hey');
function toggle(source) {
checkboxes = document.getElementsByName('options');
for(var i=0, n=checkboxes.length;i<n;i++) {
checkboxes[i].checked = source.checked;
}
}
</script>

<form>
<input type="checkbox" value="All" onClick="toggle(this)" />All
<input type="checkbox" class="checkbox1" name="options" value="Option1" id="opt1">Option 1
<input type="checkbox" class="checkbox1" name="options" value="Option2" id="opt2">Option 2
<input type="checkbox" class="checkbox1" name="options" value="Option3" id="opt3">Option 3
</form>


The alert shows up. But the function Check All is not working. I tried it on a Notepad, and it's working. But in a WordPress page, it's not.


Please help. Thanks!





Aucun commentaire:

Enregistrer un commentaire