2
我的源代碼中有以下內容,我希望能夠灰色公司和停靠,禁用,如果有人選擇運輸或存儲如果從項目中選擇,則禁用輸入
<select name="myselect" id="myselect">
<option value="shipping">Shipping</option>
<option value="Recieving" selected="selected">Reciving</option>
<option value="Storage">Storage</option>
</select>
company:<input name="company" type="text" id="company" /></div>
dock:<input name="dockingStation" type="text" id="dock" />
編輯
我試過這個但是現在它刪除禁用的attribut但不添加它
<select name="myselect" id="myselect">
<option value="shipping">Shipping</option>
<option value="Recieving" selected="selected">Reciving</option>
<option value="Storage">Storage</option>
</select>
company:<input name="company" type="text" id="company" **disabled="disabled**"/>
dock:<input name="dockingStation" type="text" id="dock" disabled="disabled" />
和jquery是
$("#myselect").change(function() {
var val = $(this).val();
if(val == "shipping" || val == "storage") {
$("#company").attr("disabled", true) // this works
}否則{ $(「#company」)。removeAttr(「disabled」) .focus() } });
但是現在一旦啓用我就無法再次禁用它
編輯
現在工作
它不添加禁用= 「禁用」 中的輸入 – Autolycus 2011-06-16 00:00:35
@Autolycus - 你的意思是什麼? – karim79 2011-06-16 00:02:19
它沒有使輸入禁用 – Autolycus 2011-06-16 00:12:59