GIF image not clickable, but perimiter is.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • billt
    New Member
    • Apr 2014
    • 2

    #1

    GIF image not clickable, but perimiter is.

    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.getEle mentByID 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





    Code:
    <div id="status"> 
    <a id="led52" onclick="newAJAXCommand('leds.cgi?led=52');"><DIV id="MSP_MAP_SEL"></DIV></a> 
    </div> 
    
    <script type="text/javascript"> <!--
    
    function updateStatus(xmlData) {
    	var ATSE_PTS = '<IMG SRC="http://bytes.com/ATSE-PTS_3.gif" ALT="ATSE-PTS" WIDTH=225 HEIGHT=150>';
    	var MSP_GE = '<IMG SRC="http://bytes.com/MSP-GE_3.gif" ALT="MSP-GE" WIDTH=225 HEIGHT=150>';
    	var MAP_GE = '<IMG SRC="http://bytes.com/MAP-GE_3.gif" ALT="MAP-GE" WIDTH=225 HEIGHT=150>';
    
    	for(i = 0; i < 74; i++)
    
    		if (getXMLValue(xmlData, 'led' + i) == 0) 
    		{
    			if(i == 52)
    			{
     			document.getElementById('MSP_MAP_SEL').innerHTML = ATSE_PTS;
    			}
    		}
    		else if (getXMLValue(xmlData, 'led' + i) == 1) 
    		{
    			if(i == 52)
    			{
     			document.getElementById('MSP_MAP_SEL').innerHTML = MSP_GE;
    			}
    		}
    		else if (getXMLValue(xmlData, 'led' + i) == 2)
    		{
    			if(i == 52)
    			{
     			document.getElementById('MSP_MAP_SEL').innerHTML = MAP_GE;
    			}
    		}
    }
    setTimeout("newAJAXCommand('status.xml', updateStatus, true)",500);
    
    
    //--> </script>
    Last edited by Rabbit; Apr 28 '14, 03:47 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • billt
    New Member
    • Apr 2014
    • 2

    #2
    Thank you Rabbit. I was unaware of that.

    Comment

    Working...