一旦使用 Javascript 和 AJAX 选择了特定的下拉项,我试图禁用某些文本字段。我的 HTML 代码如下:
<html>
<li>
<span class="label">Rate Type: </span>
<label class="alignleft">
<select class="customSelect"name="Rate" onChange="findSelected()" id="Rate2">
<option>Fixed</option>
<option>Fixed</option>
<option value="variable">Variable</option>
</select>
</label>
</li>
<li>
<span class="label">Mortgage Interest Rate :</span>
<label class="alignleft"><span class="percent">%</span><input type="text" class="textfield" value=5 name="Iint"/></label>
</li>
<li>
<span class="label multiline">Amount Borrower want to repay: </span>
<label class="alignleft"><input type="text" class="textfield" value=10000 name="Ipay"/></label>
</li>
<li>
<span class="label multiline">Posted Interest Rate for Similar Mortgages</span>
<label class="alignleft"><span class="percent">%</span><input type="text" class="textfield" value=3 name="Iintsim"/></label>
</li>
<li>
<span class="label">Mortgage Interest Rate :</span>
<label class="alignleft twofield"><strong class="percent">%</strong><input type="text" class="textfield" value=1.30 Name="Mint" /></label>
</li>
</html>
我的Javascript代码如下:
function findSelected(){
var xhttpr = new XMLHttpRequest();
// xhttpr.open("GET","index.html",true);
// xmlhttp.send();
var rate= document.getElementById('Rate2');
var variable = document.getElementById('variable');
if(rate.value == "variable"){
alert("hi");
Iint.disabled=false;
Ipay.disabled=false;
Iintsim.disabled=false;
} else {
Iint.disabled=true;
Ipay.disabled=true;
Iintsim.disabled=true;
}
}
我确定我正在做一些事情,如果不是很多,事情是错误的。请告诉我。谢谢!