...

View Full Version : Changing an INPUT's SRC....



isaaclloyd
03-24-2005, 06:01 PM
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~

afru
03-24-2005, 06:13 PM
Use this code instead....



document.getElementById("g0").src='images/box_time.gif';


It really works...

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

Afru.

Willy Duitt
03-24-2005, 08:06 PM
I also wonder why getAttribute('src') not supported.

getAttribute('src') returns the current value...
setAttribute('src') sets a new value...

.....Willy

isaaclloyd
03-24-2005, 08:42 PM
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~

Willy Duitt
03-24-2005, 09:19 PM
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... :rolleyes:

What the heh is: .setElementById

.....Willy

BTW: Please use bbCode
...CODE HERE... 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...

isaaclloyd
03-24-2005, 09:25 PM
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~



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum