ri************* ***@gmail.com wrote:
Hey Rob,
Please don't top post, reply below trimmed quotes.
When I replaced it with the line you told me JavaScript thows the Error
Below:-
Microsoft JScript runtime error: 'options' is null or not an object
Probably because I expected you to be using a select element rather
than a set of checkboxes. Your original post was somewhat confusing,
here is an example of getting the selected checkboxes from a set:
<script type="text/javascript">
function listValuesCheck Box(checkBoxRef )
{
var list = [];
for (var i=0, len=checkBoxRef .length; i<len; i++){
if (checkBoxRef[i].checked){
list.push(check BoxRef[i].value);
}
}
alert(list.join ('\n'));
}
</script>
<form action="">
<label for="cb01"><inp ut type="checkbox" id="cb01"
name="cbSet1" value="cb 01">cb 01</label><br>
<label for="cb02"><inp ut type="checkbox" id="cb02"
name="cbSet1" value="cb 02">cb 02</label><br>
<label for="cb03"><inp ut type="checkbox" id="cb03"
name="cbSet1" value="cb 03">cb 03</label><br>
<input type="button" value="Show checked"
onclick="listVa luesCheckBox(th is.form.cbSet1) ;">
<input type="reset">
</form>
If you are trying to create a delimited list, a joined array is simpler
(and much faster in IE) than concatenating strings using the "+="
compound operator.
--
Rob