View Full Version : Enable link dynamically

11-28-2005, 08:30 AM
Hi friends,

I have a multiple combo box (select box). When the user selects one or more entries from the select box then a corresponding link (<a href="somthing.html"> somthing</a>) should be enabled. When the number of entries selcted by the user equals zero, then the link should be disabled.

Using onChange event for select box, I am able to sense the number of entries selected. But I am not able to disable a link dynamilcally. I have even got code to enable a link dynamically. But the code doesn't work for disabling the link.

Thanks in advance,

11-28-2005, 09:01 AM
Here's one way:

<input type="button" value="Disable" onclick="document.getElementById('dlink').removeAttribute('href', 0)">
<a id="dlink" href="some.htm">Click</a>

To re-enable the link do:

<input type="button" value="Enable" onclick="document.getElementById('dlink').setAttribute('href', 'some.htm', 0)">

11-28-2005, 09:41 AM

It is working!! Thanks a lot for getting me the solution in zero time :)

Thanks & Regards,