Results 1 to 3 of 3

Thread: Enable link dynamically

  1. #1
    Join Date
    Nov 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Enable link dynamically

    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,
    Navanee

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Here's one way:

    HTML Code:
    <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:

    HTML Code:
    <input type="button" value="Enable" onclick="document.getElementById('dlink').setAttribute('href', 'some.htm', 0)">
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Nov 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    John,

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

    Thanks & Regards,
    Navanee

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •