[Javascript] URGENT: Object required error in onClick event

Michael J. Mahony lists at mahonyconsulting.com
Thu Jun 20 09:53:25 CDT 2002


Hi,

I'm getting frustrated by this code and thought I would ask for some 
help.

I've got a simple onClick handler in my code.  However, when I click the 
item I want to fire off the onClick handler I'm told that an object is 
required.  It basically just does not see the function I've designed to 
handle the onClick event.  Here is the relevant portion of the HTML 
code:

<td><input type="checkbox" value="0.99-11229" name="3168" 
onClick="clicked11229();">Add Kid's Shake<i>(add
0.99)</i></td></tr><tr><td>&nbsp;</td><td>&nbsp;&nbsp;&nbsp;&nbsp;
<input
type="checkbox" value="0.00-11230" name="3169">Vanilla<i>(add
0.00)</i></td></tr><tr><td>&nbsp;</td><td>&nbsp;&nbsp;&nbsp;&nbsp;
<input
type="checkbox" value="0.00-11231" name="3169">Chocolate<i>(add
0.00)</i></td></tr><tr><td>&nbsp;</td><td>&nbsp;&nbsp;&nbsp;&nbsp;
<input
type="checkbox" value="0.00-11232" name="3169">Strawberry<i>(add
0.00)</i></td>


And here is the relevant JavaScript code:

<script language="javascript 1.0">
<!--

function clicked11229()
{
if(document.forms.orderoptions.3168.checked!=true)
{
alert('Got here');
document.forms.orderoptions.3169[0].checked=false;
document.forms.orderoptions.3169[1].checked=false;
document.forms.orderoptions.3169[2].checked=false;
}
}

//-->
</script>

I've also tried modifying this as follows:

<script language="javascript 1.0">
<!--

function clicked11229()
{
if(document.orderoptions.3168.checked!=true)
{
alert('Got here');
document.orderoptions.3169[0].checked=false;
document.orderoptions.3169[1].checked=false;
document.orderoptions.3169[2].checked=false;
}
}

//-->
</script>

but it still fails.

What am I doing wrong?

Thanks!



More information about the Javascript mailing list