Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

diabling the image with javascript

Status
Not open for further replies.

spicymango

Programmer
May 25, 2008
119
CA
Hi,

I have an image which submits the form
Code:
<td align="left"> <input name="edocsTradeConfirmations" type="image"  ALT="Search"   SRC="/images/b_Search.gif"  BORDER="0" HEIGHT="21" WIDTH="68" /></td>

Is is possible to disable the image using javascript?

Thanks
 
Suppose that input is the first element of the name edocsTradeConfirmations, you can put this line in some handler.
[tt] document.getElementsByName("edocsTradeConfirmations")[0].disabled=true;[/tt]
 
thanks a lot, your code works. I have a question I have only one element name "edocsTradeConfirmations". Not an array. In that case, shouldn't the following code should work , but it does not.
Code:
document.getElementsByName("edocsTradeConfirmations").disabled=true
 
This kind of thing is to progress by specification, not by imagination however it sounds plausible to one's habit of thinking. The method returns an array, and you've to deal with it as such.
 
sorry I got confused by

Code:
document.getElementById("mytext").disabled=true

where it return only one element, but we don't have anything like getElementByName we have getElementsByName which return collection ....... thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top