Welcome visitor
* Login
* Register
It is currently May 21st, 2019, 12:35 am
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » JavaScript



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  enable/disable with dropdown
PostPosted: August 15th, 2009, 2:55 am 

Posts: 21
I have a dropdown and an input field. The dropdown has a yes or no option. The input is disabled by default.

Do you know how can i enable the input when the dropdown has the "yes" option selected?

Thanks, im kind of newbie with javascript.


Top
 Profile  
 
  Re: enable/disable with dropdown
PostPosted: August 15th, 2009, 8:25 am 
User avatar

Posts: 79
<body onload="validate(document.getElementById('drop').value);">
<form>
<select id="drop" onchange="validate(this.value);">
<option value="0">no</option>
<option value="1">yes</option>
<input disabled="disabled" id="inputDisabled">
</form>
<script>
function validate(x){
if (x==1){document.getElementById('inputDisabled').disabled=false;}
else{document.getElementById('inputDisabled').disabled=true;}}
</script>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Client Side » JavaScript


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron