Web Analytics Made Easy -
StatCounter Has no properties - CodingForum

Announcement

Collapse
No announcement yet.

Has no properties

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Has no properties

    When I use the following in Mozilla I get the error

    document.getElementById(rad_name) has no properties

    Can someone please explain this and how to rectify it



    <script language="JavaScript">
    <!--
    rad_on="radio_on.gif"

    function rad_click(rad_name){
    document.getElementById(rad_name).src = rad_on
    }
    // -->
    </script>

    <img onclick="rad_click(this.name)" src="radio_off.gif" name="mypic">
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #2
    Because the image had no id attribute matching the rad_name argument. Set an id on the image as well, or use document.images[rad_name] instead.
    liorean <[[email protected]]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

    Comment


    • #3
      or to u could just send this to the function

      then
      rad_name.src=rad_on

      should assign the picture to the send element

      Comment


      • #4
        Thank you.

        It's amazing, so simple yet so important

        The silent one.

        The most dangerous thing in the world is an idea.
        The most dangerous person in the world is the one with an idea.

        Comment

        Working...
        X