一旦我完成我的表格,回答我的所有问题并点击计算,我想要什么,我希望能够看到结果为 1234 美元而不是 1234 美元。有没有办法做到这一点。
另外我可能想这样显示您的总成本是:1234 美元(基于提交的数据),然后是添加到配置文件之类的按钮。请帮忙!先感谢您!
脚本:
<script>function calculate() {
var total = (parseInt($('#studenttut option:selected').val()) + parseInt($('#campusrb>option:selected').val())) * parseInt($('#yearsatten>option:selected').val());
$("#total").text(total);
}
</script>
HTML:
<form>
<div id="1">
<table width="100%">
<tr>
<td>Are you an In-State-Student?</td>
<td align="right">
<select id="studenttut">
<option value="<?php echo $NIST; ?>">Yes $<?php echo $IST; ?></option>
<option value="<?php echo $NOST; ?>">No $<?php echo $OST; ?></option>
</select>
</td>
</tr>
</table>
</div>
<div id="2">
<table width="100%">
<tr>
<td>Are you staying on campus?</td>
<td align="right">
<select id="campusrb">
<option value="<?php echo $NBS; ?>">Yes $<?php echo $BS; ?</option>
<option value="1">No $0</option>
</select>
</td>
</tr>
</table>
</div>
<div id="3">
<table width="100%">
<tr>
<td>How many years are you planning to attend?</td>
<td align="right">
<select id="yearsatten">
<option value="1">1</option>
<option value="2">2</option>
<option value="2">3</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
</select>
</td>
</tr>
</table>
</div>
<div id="4">
<div id="total"><input type="button" onClick="calculate()" value="calculate"/></div>
</form>
</div>