我不知道如何使用選擇框選項啓用和禁用文本字段。啓用和禁用使用選擇框更改
也許我在下面的代碼中完全寫錯了。 如果我這樣做,請告訴我正確的代碼。
<body>
<table width="500" border="1">
<form style="text-align:center" id="form1" name="form1" method="post" action="">
<tr>
<th width="32" nowrap="nowrap">Status</th>
<th width="32" nowrap="nowrap">Runs</th>
<th width="16" nowrap="nowrap">6</th>
</tr>
<?php
$('#Status1').change(function(){
var theVal = $('#Status1').val();
switch(theVal){
case'0':
$('#Runs1').prop('disabled', true);
break;
case'1':
$('#Runs1').prop('disabled', false);
break;
case'2':
$('#Runs1').prop('disabled', true);
break;
}
});
?>
<tr>
<td align='center'>
<select id='Status1'><option value='0'>Not Playing</option><option value='1'>Playing</option><option value='2'>Out</option></select></td>
<td align='center'>
<input style='font-weight:bold; background:#FFFFFF; text-align:right; color:#000000;' disabled='disabled' name='Runs1' type='text' id='Runs1' size='5' maxlength='5' value='' />
</td>
</tr>
</form>
</table>
</body>
PHP ???? jQuery的! – 2013-03-05 10:23:35
你是在開玩笑@PSR,而不是PHP標籤,它應該是腳本標籤,這個函數應該是$(document).ready函數。 – 2013-03-05 10:23:53
哪裏包括你的JQuery文件? – 2013-03-05 10:24:10