By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,945 Members | 1,354 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,945 IT Pros & Developers. It's quick & easy.

image swapping - js and webserver portibiltiy

P: n/a
Hi -

I have a page that has a button that makes a prompt appear for the user
to type input. When they have typed in input, I want the button to
change
color when the prompt closes. I am trying to do image swapping

This snippet will prevent 'null' from appearing initially and
successfully
records user changes (typing in a comment)

var existing = form.elements[type].value;
if (existing == null) {
existing = "";
}
var comments = prompt("Enter Comment ", existing);
form.elements[type].value = comments;

Now my problem. just below the code above I am trying

alert("document.images[9].src=" + document.images[9].src);
if (comments == null) {
document.images[9].src=document.images["images/buttonComments.gif"];
}
else {
document.images[9].src=document.images["images/buttonCommentsPresent.gif"];

}

The problem is that the alert shows the address of the image as
http://localhost:9080/mystuff/images/image1.gif

and when I swap it out the new image does not show up - a red X

The images will always be under /images on every server - how can I
make this code portible without having to hardcode the 'http:etc" ?

Thanks

Tom

Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
uNConVeNtiOnAL <to****@visi.com> writes:
document.images[9].src=document.images["images/buttonComments.gif"];


This is not right. You probably mean:
document.images[9].src="images/buttonComments.gif";
(and ditto for the next assignment)

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

P: n/a
YOU SIR, ARE A GODSEND!!!!

thanks

Tom

Lasse Reichstein Nielsen wrote:
uNConVeNtiOnAL <to****@visi.com> writes:
document.images[9].src=document.images["images/buttonComments.gif"];


This is not right. You probably mean:
document.images[9].src="images/buttonComments.gif";
(and ditto for the next assignment)

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'


Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.