dzirkelb
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-Ope nPOs.asp?I D="+PartID
if (document.images["imgPlusM inus"+i].s rc = "images/Plus.jpg")
{
alert(document.images["img PlusMinus" +i].src)
document.images["imgPlusMi nus"+i].sr c = "images/Minus.jpg"
alert(document.images["img PlusMinus" +i].src)
}else{
alert("Minus")
document.images["imgPlusMi nus"+i].sr c = "images/Plus.jpg"
}
intI = i
xmlHttp=GetXmlHttpObject(s tateChange d)
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?
[code]
function ShowOpenPOs(i, PartID)
{
var url="PastDueOpenOrders-Ope
if (document.images["imgPlusM
{
alert(document.images["img
document.images["imgPlusMi
alert(document.images["img
}else{
alert("Minus")
document.images["imgPlusMi
}
intI = i
xmlHttp=GetXmlHttpObject(s
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%
[/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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yup, that did the trick...thanks!!
You're welcome! Thanks for the points!
>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.