【发布时间】:2014-10-30 05:15:26
【问题描述】:
好的,我有几个问题。
我怎样才能让我的总数有一个 $,我怎样才能在 Total 这个词旁边上移:(所以它会并排)
一旦我得到一个总价,有没有一种方法可以将它除以 2 以将 1/2 的价格放入另一个名为“存款”的字段中,然后再将其复制到另一个名为“余额”的字段中':
我无法复制日期字段
要注意这是我发现如何添加单选按钮的地方 (Here)
这是我目前所拥有的。
这是我的表格:
Session Date: <input type="text" name="field1" id="f1" />
Session Type payment :
<input type="radio" name="sessiontypepayment" id="sessiontypepayment1" value="100.00" onclick="FnCalculate(this,'extrapeople');"> Mini Session $100.00
<input type="radio" name="sessiontypepayment" id="sessiontypepayment2" value="250.00" onclick="FnCalculate(this,'extrapeople');"> Full Session $250.00
Extra people :
<input type="radio" name="extrapeople" id="extrapeople1" value="25.00" onclick="FnCalculate(this,'sessiontypepayment');"> 1 person $25.00
<input type="radio" name="extrapeople" id="extrapeople2" value="50.00" onclick="FnCalculate(this,'sessiontypepayment');"> 2 people $50.00
<input type="radio" name="extrapeople" id="extrapeople3" value="75.00" onclick="FnCalculate(this,'sessiontypepayment');"> 3 people $75.00
<input type="radio" name="extrapeople" id="extrapeople4" value="100.00" onclick="FnCalculate(this,'sessiontypepayment');"> 4 people $100.00
Total Amount: <div id="total"></div>
Deposit Amount:
Balance Amount:
balance due BY: <input type="text" name="field2" id="f2" />
这是我目前拥有的脚本。
<script type="text/javascript">
$(document).ready(function(){
$("#f1").keyup(function(){
var f2Text = $('#f2').val() + $(this).val();
$('#f2').val(f2Text );
});
});
</script>
<script>
function FnCalculate(id,name)
{
var total=0;
if(document.getElementById(name+"1").checked == true)
{
total = parseInt(document.getElementById(name+"1").value);
}
if(document.getElementById(name+"2").checked == true)
{
total = parseInt(document.getElementById(name+"1").value);
}
total = total + parseInt(id.value);
document.getElementById("total").innerHTML = total;
}
</script>
我真的很想在这方面提供帮助。
【问题讨论】:
-
var f2Text = '$'+((+$('#f2').val())+(+$(this).val())); -
感谢您对总字段的帮助,但请问我将它放在哪里,我是javascripts的新手。
-
使用
/2除以二。请注意,.val()返回一个字符串,将+放在字符串前面会将其转换为 JavaScript 中的数字。 -
你能告诉我把它们放在哪里吗?
-
等等,我没有看到你所有的问题或你的目标。
标签: javascript function contact-form-7