Hi,
I'm having a problem debugging a piece of code. I will paste the JSP version (that works) and then the exact same thing in Servlet form (that does not work). The code's function is to change a picture on mouseover and then revert onmouseout. I will paste for only one of the buttons, since they do the same thing.
JSP:
<script language='javascript'>
function changeOn(object, objectId) {
if (object == 'bookingsButton') {
document.getElementById(objectId).src = 'Images/BookingsOn.png';
} else if (object == 'detailsButton') {
document.getElementById(objectId).src = 'Images/DetailsOn.png';
}
}
function changeOff(object, objectId) {
if (object == 'bookingsButton') {
document.getElementById(objectId).src = 'Images/Bookings.png';
} else if (object == 'detailsButton'){
document.getElementById(objectId).src = 'Images/Details.png';
}
}
</script>
<body>
<img src='Images/Details.png' alt='More information' id='detail1' onMouseover="document.body.style.cursor='hand'; changeOn('detailsButton', 'detail1');" onMouseout="document.body.style.cursor='default'; changeOff('detailsButton', 'detail1');">
</body>
Servlet:
out.println("<script language='javascript'>");
out.println("function changeOn(object, objectId) {");
out.println("if (object == 'bookingsButton') {");
out.println("document.getElementById(objectId).src = 'Images/BookingsOn.png';");
out.println("} else if (object == 'detailsButton') {");
out.println("document.getElementById(objectId).src = 'Images/DetailsOn.png';");
out.println("}");
out.println("}");
out.println("function changeOff(object, objectId) {");
out.println("if (object == 'bookingsButton') {");
out.println("document.getElementById(objectId).src = 'Images/Bookings.png';");
out.println("} else if (object == 'detailsButton'){");
out.println("document.getElementById(objectId).src = 'Images/Details.png';");
out.println("}");
out.println("}");
out.println("</script>");
int rowCounter = 0;
while (flatResultSet.next()) {
rowCounter++;
out.println("<img src='Images/Details.png' alt='More information' id='detail" + rowCounter + "' onMouseover=\"document.body.style.cursor='hand'; changeOn('detailsButton', 'detail" + rowCounter + "');\" onMouseout=\"document.body.style.cursor='default'; changeOff('detailsButton', 'detail" + rowCounter + "');\">");
If you crack this, you are a genius.
Thanks,
-Ashton