Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 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">

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    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 <[lio@wg]>
    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

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    or to u could just send this to the function

    then
    rad_name.src=rad_on

    should assign the picture to the send element

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Thank you.

    It's amazing, so simple yet so important



  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •