これを試して、
Jクエリコード:
<script language="javascript" type="text/javascript" src="js/jquery-1.8.2.js"></script>
<script language="javascript" type="text/javascript">
$(function(){
$('#dropdown').change(function() {
$('#selectedValue').html($(this).val()); // just to see what value did the user select
if($(this).val()=='2'){// validating whether the user selected value 2 and disabling textbox
$('#textbox').attr('disabled', 'disabled');
}
});
});
</script>
HTML コード:
<select name="dropdown" id="dropdown">
<option id="select1" value="1" selected="selected">1</option>
<option id="select2" value="2">2</option>
<option id="select3" value="3">3</option>
<option id="select4" value="4">4</option>
</select>
<input id="textbox" type="text" value="" />
<div id="selectedValue"></div>