Reputation: 4662
I'm trying to execute 'select' function via onclick
but it doesn't work.
<script type="text/javascript">
function select() {
document.getElementById('select').disabled = true;
}
</script>
<input type="button" id="select" value="OK" onclick="select()">
Upvotes: 2
Views: 439
Reputation: 15333
Try changing the name of the Function from select to something else. select is html reserved word so doesn't work.
Upvotes: -1
Reputation: 719
<script type="text/javascript">
function mySelect() {
document.getElementById('myselect').setAttribute('disabled');
}
</script>
<input type="button" id="myselect" value="OK" onclick="mySelect()">
Two things:
a) avoid using internal names for functions or variables. select is an html reserved word; and
b) the right way to set is using the setAttribute.
Done! (and tested).
Upvotes: 2