Link to home
Start Free TrialLog in
Avatar of dzirkelb
dzirkelbFlag for United States of America

asked on

Change Picture Displayed with Mouse click

I am having troubles getting my code to change back and forth by clicking on a mouse button on an img.  Here is the javascript function:

[code]
function ShowOpenPOs(i, PartID)
{
    var url="PastDueOpenOrders-OpenPOs.asp?ID="+PartID
   
   
   
    if (document.images["imgPlusMinus"+i].src = "images/Plus.jpg")
    {
          alert(document.images["imgPlusMinus"+i].src)
        document.images["imgPlusMinus"+i].src = "images/Minus.jpg"
        alert(document.images["imgPlusMinus"+i].src)
    }else{
          alert("Minus")
        document.images["imgPlusMinus"+i].src = "images/Plus.jpg"
    }
   
      
      intI = i
    xmlHttp=GetXmlHttpObject(stateChanged)
    xmlHttp.open("GET", url , true)
    xmlHttp.send(null)
}
[/code]

Here is the img:

[code]
<img id="imgPlusMinus<%=i%>" alt="Show Open PO Details" src="images/test.jpg" onclick="ShowOpenPOs(<%=i%>, <%=rs1("ID")%>)">
[/code]

What happens from my troubleshooting is when it is a plus and then clicked, it goes to a minus...perfect.  Now, when I click it when it is a minus, it goes to a plus, then right back to a minus.  What am I doing wrong?
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Hello dzirkelb,

>Now, when I click it when it is a minus, it goes to a plus, then right back to a minus
Do you have the alert("Minus") too ?

Regards.
Avatar of dzirkelb

ASKER

Nope, it never gets to the alert...I've put all sorts of stuff in that section of the else statement just to test if it gets there, but it seems to not even get to that portion.
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yup, that did the trick...thanks!!
You're welcome! Thanks for the points!