Click to See Complete Forum and Search --> : images not loading


wynton_ca
06-23-2003, 03:59 PM
I have a function here to swap images back and forth through an onClick event that works fine in a standard flat html file. However when I plop it into my jsp page, sometimes the images show, and sometimes they come up broken. Is this a simple preload issue or maybe more extensive? Here is the function and the implementaion....

<script language="javascript">
function chng(c_img, swap1, swap2) {
if (c_img.src.indexOf(swap1)!= -1) c_img.src = swap2;
else c_img.src = swap1;
}
</script>

<a href="javascript:displaySwitching('courseOverview');"><img src="/educator_root/images/btns/btn_show-crse-details.gif" width="131" height="23" alt="" border="0" onclick="chng(this,'/educator_root/images/btns/btn_show-crse-details.gif','/educator_root/images/btns/btn_hide-crse-details.gif')" name="courseDetail" /></a>


[the href value is controlling a show/hide div layer down lower on the page]

thanks

Jona
06-23-2003, 04:06 PM
Well, is your DTD (DOCTYPE) the XHTML 1.1 or 1.0 one? If so, use ID instead of NAME, because NAME is not an XHTML attribute--and does not exist. That would be the basis of your problem. Of course, you may have to change your code alittle (may) to suit the update.

Jona

wynton_ca
06-23-2003, 04:30 PM
Here is my doctype:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">

The images swap. However, in IE they always appear on load but sometimes do not 'load' when clicked. The majority of the time they click and load normally as I expect, however Id say maybe 1 in every 10 clicks results in a broken image. Interestingly, in Netscape, the page loads with the images correctly, and even swaps to the correct image on the first click, but consequently after that, no images load onclick. Outside of the .jsp the function works correctly, however inside the jsp the code seems to break in random ways. The images are also being assigned different names based on a java/jsp looping through an iteration of items that come directly out of a database.

Jona
06-23-2003, 04:33 PM
Then your problem is a database one. Ensure that all of the images exist and that your JSP functions are getting the correct results. Also, please provide a link to your page.

[Jona]