Reputation: 108
i wanted to disable a button when the page loads depending on the privilege level of the user. i already tried this code
if($previlage != 2)
{
echo "<script>document.getElementById('US').setAttribute('disabled');</script>";
}
thanks in advance
Upvotes: 1
Views: 52
Reputation: 8033
You can do this without any javascript or jquery code:
<button <?php echo $privillage != 2 ? "disabled='disabled'" : "" ?>> Button</button>
Upvotes: 1
Reputation: 2295
thy this
if($previlage != 2)
echo "<script>document.getElementById('US').disabled = true;</script>";
make sure to print the JS after loading the button in DOM
Upvotes: 1