By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,376 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

GIF image not clickable, but perimiter is.

P: 2
I am fairly new to AJAX, JavaScript, and HTML. The below code is just a snippet of my working code, but it does not work the way I expected or want it to work. It also talks
with a server (microchip Ethernet controller microcontroller chip) running "C" code.

I have three gif images and depending upon the result I get from getXMLValue, if it's equal to 0, 1, or 2, I want one of my three different gif images to display. So I figured that the best way to do that was by using the innerHTML property of document.getElementByID to replace the HTML code with one of the three gif images based upon the condition.

I am using the onclick and AJAX code because I'm modifying example code that I started from and this is what they used. Like I'd mentioned above, while this does work, it isn't working the way I want it to work. I want to be able to click either of the three gif images and have that click be recognized by the underlying "C" code to do a particular function. But it only works if I click on a far perimiter (left or right hand side) of the image, but not if I click in the center or anywhere else on the gif image itself. What am I doing wrong here?

Thanks.

Bill





Expand|Select|Wrap|Line Numbers
  1. <div id="status"> 
  2. <a id="led52" onclick="newAJAXCommand('leds.cgi?led=52');"><DIV id="MSP_MAP_SEL"></DIV></a> 
  3. </div> 
  4.  
  5. <script type="text/javascript"> <!--
  6.  
  7. function updateStatus(xmlData) {
  8.     var ATSE_PTS = '<IMG SRC="http://bytes.com/ATSE-PTS_3.gif" ALT="ATSE-PTS" WIDTH=225 HEIGHT=150>';
  9.     var MSP_GE = '<IMG SRC="http://bytes.com/MSP-GE_3.gif" ALT="MSP-GE" WIDTH=225 HEIGHT=150>';
  10.     var MAP_GE = '<IMG SRC="http://bytes.com/MAP-GE_3.gif" ALT="MAP-GE" WIDTH=225 HEIGHT=150>';
  11.  
  12.     for(i = 0; i < 74; i++)
  13.  
  14.         if (getXMLValue(xmlData, 'led' + i) == 0) 
  15.         {
  16.             if(i == 52)
  17.             {
  18.              document.getElementById('MSP_MAP_SEL').innerHTML = ATSE_PTS;
  19.             }
  20.         }
  21.         else if (getXMLValue(xmlData, 'led' + i) == 1) 
  22.         {
  23.             if(i == 52)
  24.             {
  25.              document.getElementById('MSP_MAP_SEL').innerHTML = MSP_GE;
  26.             }
  27.         }
  28.         else if (getXMLValue(xmlData, 'led' + i) == 2)
  29.         {
  30.             if(i == 52)
  31.             {
  32.              document.getElementById('MSP_MAP_SEL').innerHTML = MAP_GE;
  33.             }
  34.         }
  35. }
  36. setTimeout("newAJAXCommand('status.xml', updateStatus, true)",500);
  37.  
  38.  
  39. //--> </script>
Apr 28 '14 #1
Share this Question
Share on Google+
1 Reply


P: 2
Thank you Rabbit. I was unaware of that.
Apr 28 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.