problem with onclick

D

Draken

I have a function in the head section of a html and call it from a radio
button with onClick="menu();" but IE tells me that the object doesnt support
this method or property. What is the problem with that? I have tried
numerous ways around it but to no avail.

<head>
function menu() {
for (i=0;i<=2;i++) {
if (document.menuform.menu.checked=="1") {
parent.main.location.href="document.menuform.menu.value + '.html'" }
}
}
</head>
<body>
<form name="menuform">
<radio name="form" value="news" onClick="menu();">
</body>

Thank you for your help,
-Dave
 
E

Evertjan.

Draken wrote on 02 jul 2003 in comp.lang.javascript:
I have a function in the head section of a html and call it from a
radio button with onClick="menu();" but IE tells me that the object
doesnt support this method or property. What is the problem with that?
I have tried numerous ways around it but to no avail.

<head>
function menu() {
for (i=0;i<=2;i++) {
if (document.menuform.menu.checked=="1") {
parent.main.location.href="document.menuform.menu.value + '.html'"
}
}
}
</head>
<body>
<form name="menuform">
<radio name="form" value="news" onClick="menu();">
</body>


No <script> tags
No closing </form>
<radio must be <input type="radio"
menuform.menu must be menuform.form, but
do not use as a name "form", it is reserved
..checked is boolean

======================

simplified, this works:

<script>
function menu() {
if (document.menuform.myform.checked)
alert(document.menuform.myform.value + '.html')
}
</script>

<body>
<form name="menuform">
<input type="radio" name="myform" value="news" onClick="menu();">
News
</form>
</body>
 
D

Draken

Sorry, I was quickly writing some tags in as a reference that isnt the
actual code, so most of your points are already covered, and im guessing the
..checked should work both ways. See I have used my function as a
href="javascript: menu();" and it works exactly how I planned it to.
I just re-read that post and realised how many errors I made, pity my first
post didnt actually send as it was much more in depth and accurate *sigh*...
anyway, here is the exact code I have, sorry.

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function menu() {
for (i=0;i<=2;i++) {
if (document.menuform.menu.checked=="1") {
parent.main.location.href="document.menuform.menu.value + '.html'" }
}
}
//--!>
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="menuform">
<INPUT TYPE="RADIO" NAME="menu" VALUE="news" onClick=""><A HREF="javascript:
menu()" onMouseOver="document.menuform.menu[0].checked='1'">News</A><BR>
<INPUT TYPE="RADIO" NAME="menu" VALUE="new" onClick=""><A HREF="javascript:
menu()" onMouseOver="document.menuform.menu[1].checked='1'">new</A><BR>
</FORM>
</BODY>
</HTML>
 
D

Draken

I forgot I had taken the error out of my html file so the onClicks are empty
as you can see... however they WERE...
<INPUT TYPE="RADIO" NAME="menu" VALUE="news" onClick="menu();">

Hey its 3am, im allowed to make mistakes at this time of the morning *yawn*
stupid brain wake up!
Thanks
-Dave
 
E

Evertjan.

Draken wrote on 02 jul 2003 in comp.lang.javascript:
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function menu() {
for (i=0;i<=2;i++) {
if (document.menuform.menu.checked=="1") {
parent.main.location.href="document.menuform.menu.value + '.html'" }
}
}
//--!>
</SCRIPT>


Loose the "" around document.menuform.menu.value+'.html'


<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function menu() {
for (i=0;i<=2;i++) {
if (document.menuform.menu.checked=="1") {
parent.main.location.href=document.menuform.menu.value+'.html'}
}
}
</SCRIPT>
 
D

Draken

Loose the "" around document.menuform.menu.value+'.html'

Nope, that didnt fix it... the error is on line 27 which is the <INPUT
TYPE="RADIO"... line and says Object doesn't support this property or
method. I at first thought that meant the .value but as I said it works fine
in a href="javascript: menu();" call
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top