我希望它是什麼,一旦我得到要通過我的形式,ansering我所有的問題和命中計算,我希望能夠看到結果作爲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>
不要用[parseInt函數沒有基數(http://stackoverflow.com/questions/7818903/JSLint的-說缺失基數參數 - 什麼 - 應該-I-DO)。 – Quentin