Posted by Janwillem Borleffs on 07/21/05 00:37
Janwillem Borleffs wrote:
> Or better yet:
>
> document.forms['survey_form'].elements['food_types[]']
>
Or with a minor modification to the JS and the function call only:
<script type="text/javascript">
function checkChoice(obj, first) {
var elements = obj.form.elements[obj.name];
elements[0].checked = obj.checked && first;
if (first) {
for (var i = 1; i < elements.length; i++) {
elements[i].checked = false;
}
}
}
</script>
....
<input type=checkbox name="food_types[]" value="No Preference"
onclick="checkChoice(this, 1)" checked>No Preference:
<br>
<input type=checkbox name="food_types[]" value="Mexican"
onclick="checkChoice(this)"> Mexican:
<br>
<input type=checkbox name="food_types[]" value="Thai"
onclick="checkChoice(this)"> Thai:
<br>
<input type=checkbox name="food_types[]" value="Unlisted Food"
onclick="checkChoice(this)">Unlisted Food
JW
Navigation:
[Reply to this message]
|