Question

in my page ther's a label which on it's content i am basing a decision such as hide an disable a cupple of controls.

there's a

<img src="images/Delete.png" alt="delete" 
   style="height: 18px; width: 24px; cursor:pointer" 
   onclick="deleteRow('<%=row["tId"] %>');" id="imgBut_dltRow" />

i would like to undersand how can i disable the click event *or the img/button response like in :

if(document.getElementById("LBL_isManager").value != "")
disable click event / or totaly disable this "imgBut_dltRow"

i couldnt disable it from code behind cause it has <% %> c# tags so i could not make it runat="server" too . only option is ask for the label value if it's not empty ("") then block that event.

thanks a lot !

Était-ce utile?

La solution

Try this - DEMO

document.getElementById("imgBut_dltRow").addEventListener("click", function(e) {
    if ( document.getElementById("LBL_isManager").value != "" ) {
        e.stopImmediatePropagation();
    }
}, false);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top