有兩個選擇按鈕需要客戶端驗證。用戶必須選擇其中一個,如果用戶選擇其中一個,另一個將自動禁用。如何使用JavaScript禁用HTML表單元素?
這是我的腳本:
<html>
<head>
<script type="text/javascript">
function Check() //this the funciton for diasbled
{
var x =document.getElementById("supexp1");
var y =document.getElementById("supexp2");
if(x.value != "")
{
document.form1.supexp2.disabled=true;
}
else if(y.value != "")
{
{
document.form1.supexp1.disabled=true;
}
}
}
</script>
</head>
<body>
<form method="POST" action="destination.php" id="form1">
<select name="SUPEXP" id="supexp1" data-native-menu="false" onChange="Check()">
<option >Ekspedisi Local1</option> //this selection 1
<option >Ekspedisi Local2</option> //this selection 1
<option >Ekspedisi Local3</option> //this selection 1
</select>
<select name="SUPEXP" id="supexp2" data-native-menu="false" onChange="Check2()">
<option >Ekspedisi Expor2</option> //this selection 2
<option >Ekspedisi Expor2</option> //this selection 2
<option >Ekspedisi Expor2</option> //this selection 2
</select>
</form>
</body>
</html>
我使用jquerymobile框架和選擇連接到數據庫。該代碼(JavaScript)未運行。
你在哪裏導入jquerymobile? – 2012-07-28 04:15:39
@LarryBattle我支持標籤
之間的Jquery手機..,有什麼問題嗎? – MudMan23 2012-07-28 04:19:58