image swapping - js and webserver portibiltiy

U

uNConVeNtiOnAL

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
 
L

Lasse Reichstein Nielsen

uNConVeNtiOnAL said:
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
 
U

uNConVeNtiOnAL

YOU SIR, ARE A GODSEND!!!!

thanks

Tom
uNConVeNtiOnAL said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top