View Single Post
  #1 (permalink)  
Old July 21st, 2005, 05:58 AM
vinkumrect vinkumrect is offline
Registered User
 
Join Date: Jul 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

Reply With Quote