problem with onclick

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Draken

    problem with onclick

    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.menuf orm.menu[i].checked=="1") {
    parent.main.loc ation.href="doc ument.menuform. menu[i].value + '.html'" }
    }
    }
    </head>
    <body>
    <form name="menuform" >
    <radio name="form" value="news" onClick="menu() ;">
    </body>

    Thank you for your help,
    -Dave


  • Evertjan.

    #2
    Re: problem with onclick

    Draken wrote on 02 jul 2003 in comp.lang.javas cript:
    [color=blue]
    > 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.menuf orm.menu[i].checked=="1") {
    > parent.main.loc ation.href="doc ument.menuform. menu[i].value + '.html'"
    > }
    >}
    >}
    > </head>
    > <body>
    > <form name="menuform" >
    > <radio name="form" value="news" onClick="menu() ;">
    > </body>
    >[/color]

    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.menuf orm.myform.chec ked)
    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)

    Comment

    • Draken

      #3
      Re: problem with onclick

      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="javascrip t: 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="JavaS cript">
      <!--
      function menu() {
      for (i=0;i<=2;i++) {
      if (document.menuf orm.menu[i].checked=="1") {
      parent.main.loc ation.href="doc ument.menuform. menu[i].value + '.html'" }
      }
      }
      //--!>
      </SCRIPT>
      </HEAD>
      <BODY>
      <FORM NAME="menuform" >
      <INPUT TYPE="RADIO" NAME="menu" VALUE="news" onClick=""><A HREF="javascrip t:
      menu()" onMouseOver="do cument.menuform .menu[0].checked='1'">N ews</A><BR>
      <INPUT TYPE="RADIO" NAME="menu" VALUE="new" onClick=""><A HREF="javascrip t:
      menu()" onMouseOver="do cument.menuform .menu[1].checked='1'">n ew</A><BR>
      </FORM>
      </BODY>
      </HTML>


      Comment

      • Draken

        #4
        note to above post... mistake

        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


        Comment

        • Evertjan.

          #5
          Re: problem with onclick

          Draken wrote on 02 jul 2003 in comp.lang.javas cript:
          [color=blue]
          > <HTML>
          > <HEAD>
          > <SCRIPT LANGUAGE="JavaS cript">
          > <!--
          > function menu() {
          > for (i=0;i<=2;i++) {
          > if (document.menuf orm.menu[i].checked=="1") {
          > parent.main.loc ation.href="doc ument.menuform. menu[i].value + '.html'" }
          >}
          >}
          > //--!>
          > </SCRIPT>
          >[/color]

          Loose the "" around document.menufo rm.menu[i].value+'.html'


          <HTML>
          <HEAD>
          <SCRIPT LANGUAGE="JavaS cript">
          function menu() {
          for (i=0;i<=2;i++) {
          if (document.menuf orm.menu[i].checked=="1") {
          parent.main.loc ation.href=docu ment.menuform.m enu[i].value+'.html'}
          }
          }
          </SCRIPT>


          --
          Evertjan.
          The Netherlands.
          (Please change the x'es to dots in my emailaddress)

          Comment

          • Draken

            #6
            Re: problem with onclick

            > Loose the "" around document.menufo rm.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="javascrip t: menu();" call


            Comment

            Working...