p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Javascript How-To (http://p2p.wrox.com/forumdisplay.php?f=87)
-   -   Problem with input type image With Anchor tag (http://p2p.wrox.com/showthread.php?t=31722)

vinkumrect July 21st, 2005 05:58 AM

Problem with input type image With Anchor tag
 
Hi,

     I'm having problem in input type image.Follwing is my code. When the page loads i'm adding one image input type and setting some attributes. My requirement is initially i want to disable the image. But i added code for disabling the image but still i can able to get the click event on image. What is the problem in my code?


var FirstTD = document.createElement('TD');
FirstTD.setAttribute('class','ms-toolbar');
FirstTD.setAttribute('width','34');
var FirstTDAtag = document.createElement('A');
FirstTDAtag.setAttribute('class','ms-toolbar ');
FirstTDAtag.setAttribute('accessKey','F');
FirstTDAtag.setAttribute('tabindex','2');
FirstTDAtag.setAttribute('href','javascript:test() ');
FirstTDAtag.setAttribute('target','_self');
var FirstTDImgtag = document.createElement('input');
FirstTDImgtag.setAttribute('type','image');
FirstTDImgtag.disabled = true;
FirstTDImgtag.setAttribute('id','Fimgid');
FirstTDImgtag.setAttribute('alt','Forward');
FirstTDImgtag.setAttribute('src','http://'+document.location.hostname+'/_layouts/images/FBACK.GIF');
FirstTDImgtag.setAttribute('border','0');
FirstTDAtag.appendChild(FirstTDImgtag);
FirstTD.appendChild(FirstTDAtag);
FirstTR.insertBefore(FirstTD,OldTD1);

When my page get loads image is showing in the page without disabled. When i click the image its showing alert message of function test(). How come its possible?

When i comment out the line FirstTDImgtag.disabled = true; and after refreshing when i click the image the i'ts not getting into the function test() instead its refreshing the page.

Is anybody know solution for my problem please let me know how to solve it?

Thanks and Regards,
Vinoth


joefawcett July 21st, 2005 08:59 AM

Try appending the image to the page before setting the disabled attribute.

--

Joe (Microsoft MVP - XML)


All times are GMT -4. The time now is 11:35 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.