我想,當select
箱的設定值,acct
已更改爲清除Input
領域totalA
和qtyA
的當前值。清除輸入文本字段已經改變
到目前爲止我有這個代碼,但我不確定在哪裏清除值。
<script language="javascript">
$(document).ready(function() {
$("#acct").on('change', function() {
var selVal = $(this).val();
if (selVal == 'Full-Time') { // Full Time
$('.parttime').hide();
$('.fulltime').show();
$('.agent').show();
$('.error').hide();
}
else if (selVal == 'Part-Time') { // Part Time
$('.parttime').show();
$('.fulltime').hide();
$('.agent').show();
$('.error').hide();
}
else {
$('.parttime').hide();
$('.fulltime').hide();
$('.agent').hide();
$('.error').show();
}
});
$('#qtyA').on('change', function() {
var selVal = $("#acct").val();
if (!isNaN($(this).val())) {
var total = 0;
if (selVal == 'Full-Time') {
total = parseInt($(this).val()) * 1280;
}
else if (selVal == 'Part-Time') {
total = parseInt($(this).val()) * 720;
}
$('#totalA').val(total.toFixed(2));
}
else {
$(this).val('0');
$('#totalA').val('0.00');
}
});
});
</script>
的select
框代碼:
<p>
<label for="acct" style="margin-right:45px;"><strong />Account Type<strong><font color="red" size="3"> * </font></strong></label>
<select name="acct" style="background-color:white;" id="acct" value="" class="validate[custom[cname]] text-input">
<option value="Full-Time">Full-Time</option>
<option value="Part-Time">Part-Time</option>
<option selected="selected" value=""></option>
</select>
</p>
的Input
領域:
<p>
<table class="agent">
<tr>
<td>
<lable style="margin-right:89px;"># of Agent(s)<font color="red" size="3"> * </font></lable>
</td>
<td>
<input style="width:25px; margin-left:5px;" type="text" name="qtyA" id="qtyA" />
</td>
<td>
X $<label id="acctFull Time" class="desc fulltime" style="display:none">1280</label>
<label id="acctPart Time" class="desc parttime" style="display:none">720</label> =
</td>
<td>
$<input style="width:65px; margin-left:5px;" type="text" readonly="readonly" name="totalA" id="totalA" onchange="calculate()" />
</td>
</tr>
</table>
</p>
<p class="error" align="center">Please select an Account Type.</p>
沒有工作您的想法是正確的,但腳本實施時不起作用。 – telexper
好的,我將你的想法添加到我的腳本 – telexper
用我的** scriptCode **看到這個[jsFiddle](http://jsfiddle.net/HbUmv/)。爲我工作! _Pls迴應,如果它也適合你 –