[英]Automat js form calculator
I need help with a js/jquery automat form calculator 我需要js / jquery自动表格计算器的帮助
the function is time=games*(players*15)
, 函数是time=games*(players*15)
,
so basicly there are 3 form fields games
players
result in field time
. 所以basicly有3个表单字段games
players
造成现场time
。
i want the result to be in real time not by pressing a button. 我希望结果是实时的,而不是按按钮。
Here is the code i made with a trigger button, but i want without calculate button, just by completing fields. 这是我用触发按钮制作的代码,但是我只想填写字段就不需要计算按钮。
Nvm, i resolved it with an onChance for fields. Nvm,我用字段的onChance解决了它。 thnx anyway. 无论如何。
<SCRIPT LANGUAGE="JavaScript">
function CalculateSum(games, players, form)
{
var A = parseFloat(games);
var B = parseFloat(players);
form.Time.value = A*(B*15) ;
}
function ClearForm(form)s
{
form.input_A.value = "";
form.input_B.value = "";
form.Time.value = "";
}
// end of JavaScript functions -->
</SCRIPT>
// HTML -->
<FORM NAME="Calculator" METHOD="post">
<P>Games: <INPUT TYPE=TEXT NAME="input_A" SIZE=10></P>
<P>Plyers <INPUT TYPE=TEXT NAME="input_B" SIZE=10></P>
<P><INPUT TYPE="button" VALUE="Calculate time" name="Calculate time"
onClick="CalculateSum(this.form.input_A.value, this.form.input_B.value, this.form)"></P>
<P><INPUT TYPE="button" VALUE="Clear" name="Clear" onClick="ClearForm(this.form)"></P>
<P>Time = <INPUT TYPE=TEXT NAME="Time" SIZE=12></P>
</FORM>
您可以使用功能keyup()
来触发功能,以便每次用户添加数字时结果都会更新
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.