By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,382 Members | 1,645 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,382 IT Pros & Developers. It's quick & easy.

problem with onclick

P: n/a
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[i].checked=="1") {
parent.main.location.href="document.menuform.menu[i].value + '.html'" }
}
}
</head>
<body>
<form name="menuform">
<radio name="form" value="news" onClick="menu();">
</body>

Thank you for your help,
-Dave
Jul 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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[i].checked=="1") {
parent.main.location.href="document.menuform.menu[i].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>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2

P: n/a
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[i].checked=="1") {
parent.main.location.href="document.menuform.menu[i].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>
Jul 20 '05 #3

P: n/a
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
Jul 20 '05 #4

P: n/a
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[i].checked=="1") {
parent.main.location.href="document.menuform.menu[i].value + '.html'" }
}
}
//--!>
</SCRIPT>


Loose the "" around document.menuform.menu[i].value+'.html'
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function menu() {
for (i=0;i<=2;i++) {
if (document.menuform.menu[i].checked=="1") {
parent.main.location.href=document.menuform.menu[i].value+'.html'}
}
}
</SCRIPT>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #5

P: n/a
> Loose the "" around document.menuform.menu[i].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
Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.