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 6 of 6
  1. #1
    New Coder
    Join Date
    Dec 2002
    Location
    Washington State
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Changing an INPUT's SRC....

    I am trying to change the INPUT's SRC but this isn't working. Any idea what else to do?


    function do_this(){
    document.getElementById("g0").getAttribute('src')='images/box_time.gif';
    }

    <INPUT type="image" SRC="00.gif" NAME="image" ID="g0">




    Any comments or suggestions are greatly appreciated. Thanks.

    ~Isaac Lloyd~
    ~ Isaac Lloyd ~
    Website Design & Development
    http://www.IsaacLloyd.com

  • #2
    New Coder
    Join Date
    Aug 2004
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Use this code instead....

    Code:
    document.getElementById("g0").src='images/box_time.gif';
    It really works...

    I also wonder why getAttribute('src') not supported.

    Afru.

  • #3
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by afru
    I also wonder why getAttribute('src') not supported.
    getAttribute('src') returns the current value...
    setAttribute('src') sets a new value...

    .....Willy

  • #4
    New Coder
    Join Date
    Dec 2002
    Location
    Washington State
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Still not working.... Does it work for you guys? Remember we are changing the SRC of an INPUT and not really an image.


    function do_this(){
    document.getElementById("g0").src='images/box_time.gif';
    }

    or

    function do_this(){
    document.setElementById("g0").src='images/box_time.gif';
    }

    <INPUT TYPE="image" SRC="00.gif" NAME="luckyimage" ID="g0" onclick="checkluckyimg();">



    Thanks for your time....


    ~Isaac Lloyd~
    ~ Isaac Lloyd ~
    Website Design & Development
    http://www.IsaacLloyd.com

  • #5
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by isaaclloyd
    Still not working.... Does it work for you guys? Remember we are changing the SRC of an INPUT and not really an image.


    function do_this(){
    document.getElementById("g0").src='images/box_time.gif';
    }

    or

    function do_this(){
    document.setElementById("g0").src='images/box_time.gif';
    }

    <INPUT TYPE="image" SRC="00.gif" NAME="luckyimage" ID="g0" onclick="checkluckyimg();">



    Thanks for your time....


    ~Isaac Lloyd~
    Comprehension is certainly underrated nowadays...

    What the heh is: .setElementById

    .....Willy

    BTW: Please use bbCode [code] ...CODE HERE...[/code] rather than the bold tags you are currently using... Not only does bbCode code tags allow for preservation of formatting but quite frankly, trying to read unformatted bold text is a PITA...

  • #6
    New Coder
    Join Date
    Dec 2002
    Location
    Washington State
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Isn't it Getting an Element By ID instead of getting it by name or something? and yea np about the [code]. Thanks again for your time.


    ~Isaac Lloyd~
    ~ Isaac Lloyd ~
    Website Design & Development
    http://www.IsaacLloyd.com


  •  

    Posting Permissions

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