我正在尝试清除Input
字段的当前值,totalA
并且qtyA
当一个select
框的选定值acct
已更改时。
到目前为止我有这段代码,但不确定在哪里清除这些值。
<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>