Kiran
Kiran

Reputation: 21

Disable Hyperlink

I have two Hyper Links

var create = dojo.create("div",{
            id:"create_links",
            className:"iconRow1",
            innerHTML:"<a class='popupLink' href='javascript:openCreateUserDialog()'>Create </a> <span>|</span><a  href='javascript:openFileUploadDialog()'>Batch </a>"
        }

By this line two Hyper Links are shown

My requirement is that , on click of the Batch Hyper Link , i want to disable the Create Hyper Link .

Please tell me how to do this ??

Upvotes: 2

Views: 3021

Answers (1)

Anders Fjeldstad
Anders Fjeldstad

Reputation: 10814

One solution would be to add a method that replaces the other link with a span tag with the same content, and call that method from each of the methods openCreateUserDialog and openFileUploadDialog. The method could look something like this:

function disableLink(linkId) {
    var link = document.getElementById(linkId);
    if (link) {
        var label = document.createElement('span');
        label.innerHTML = link.innerHTML;
        link.parentNode.replaceChild(label, link);
    }
}

This would require you to give each of your links an ID and then calling the disableLink method with the ID of the other link as a parameter when the user clicks one of the links.

Here's a fiddle with an example: http://jsfiddle.net/2AXQS/

Upvotes: 2

Related Questions