toggle image with onLoad event

B

Brian

Im trying to toggle a series of images with an onLoad event. I have my
code checking the value of a hidden textbox. Depending on the value pf
the text box, it will display one image for one and another image for
the rest of them... When the page loads, i get the same image for all
of them.. here is a snippet of my code.. When the page loads for the
first time, there should be no value, so i should get the second image
for all of them..


if (document.getElementById("testcheck").value = 'Call from Calcagni
Sign') {

document.callsign.src = Image2.src;


}

Please let me know if I am doing something wrong..

thanks in advance
 
R

RobG

Brian said:
Im trying to toggle a series of images with an onLoad event. I have my
code checking the value of a hidden textbox. Depending on the value pf
the text box, it will display one image for one and another image for
the rest of them... When the page loads, i get the same image for all
of them.. here is a snippet of my code.. When the page loads for the
first time, there should be no value, so i should get the second image
for all of them..


if (document.getElementById("testcheck").value = 'Call from Calcagni
Sign') {

If the browser supports getElementById and the element 'testcheck'
exists, you assign the string 'Call ... Calcagni' to the element's
value. Provided the above conditions, this expression will always
return true.

If, on the other hand, you intend to evaluate whether the value of
the 'testcheck' element is the same as the string 'Call ... Calcagni'
you should use evaluation '==', not an assignment '=':

if (document.getElementById('testcheck').value == 'Call...') {

[...]

Hopefully that helps.
 
B

Brian

lol.. Freaking Javascript101... DUHHHHHHH... Thanks.. That was the
problem... I've been coding vbscript far too long..
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top