toggle image with onLoad event

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brian

    #1

    toggle image with onLoad event

    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.getEl ementById("test check").value = 'Call from Calcagni
    Sign') {

    document.callsi gn.src = Image2.src;


    }

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

    thanks in advance

  • RobG

    #2
    Re: toggle image with onLoad event

    Brian wrote:[color=blue]
    > 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.getEl ementById("test check").value = 'Call from Calcagni
    > Sign') {[/color]

    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.getEl ementById('test check').value == 'Call...') {

    [...]

    Hopefully that helps.


    --
    Rob

    Comment

    • Brian

      #3
      Re: toggle image with onLoad event

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

      Comment

      Working...