我正在开发一个“计算器”(游戏),您可以在其中单击表单输入按钮,然后将数字自动添加到“总计”输入中。但是 - 我需要三个(或更多)“总”窗口。我想通过单选按钮交换您正在使用的“总窗口”。
我让它与一个“总窗口”一起工作 - 但我不确定如何交换我计算中使用的字段。
可能很简单 - 但我是 javascript 和语法的新手......
<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
function BetWIN(form) {
var MyField = eval(form.InputWIN.value)
}
function BetPLACE(form) {
var MyField = eval(form.InputPLACE.value)
}
function BetSHOW(form) {
var MyField = eval(form.InputSHOW.value)
}
function a_plus_b(form) {
a=eval(form.MyField.value)
b=eval(form.b.value)
z=a+b
form.MyField.value = z
}
function a_plus_c(form) {
a=eval(form.MyField.value)
c=eval(form.c.value)
z=a+c
form.MyField.value = z
}
function a_plus_d(form) {
a=eval(form.MyField.value)
d=eval(form.d.value)
z=a+d
form.MyField.value = z
}
function a_plus_e(form) {
a=eval(form.MyField.value)
e=eval(form.e.value)
z=a+e
form.MyField.value = z
}
function a_plus_f(form) {
a=eval(form.MyField.value)
f=eval(form.f.value)
z=a+f
form.MyField.value = z
}
function a_plus_g(form) {
a=eval(form.MyField.value)
g=eval(form.g.value)
z=a+g
form.MyField.value = z
}
function a_plus_h(form) {
a=eval(form.MyField.value)
h=eval(form.h.value)
z=a+h
form.MyField.value = z
}
// End -->
</script>
<FORM NAME="Calc">
<TABLE BORDER=4>
<TR>
<TD align="center"></TD>
<TD align="center"><input type="radio" name="BetSelector" value="InputWin" onclick="BetWIN(this.form)" checked="checked" /> WIN<br /><INPUT TYPE="text" NAME="InputWIN" Size="16" value="0" /></TD>
<TD align="center"><input type="radio" name="BetSelector" value="InputPLACE" onclick="BetPLACE(this.form)" /> PLACE<br /><INPUT TYPE="text" NAME="InputPLACE" Size="16" value="0" /></TD>
<TD align="center"><input type="radio" name="BetSelector" value="InputSHOW" onclick="BetSHOW(this.form)" /> SHOW<br /><INPUT TYPE="text" NAME="InputSHOW" Size="16" value="0" /></TD>
</TR>
<tr>
<td colspan="4">
<INPUT TYPE="button" NAME="b" VALUE="1" OnClick="a_plus_b(this.form)" class="ChipB">
<INPUT TYPE="button" NAME="c" VALUE="5" OnCLick="a_plus_c(this.form)" class="ChipC">
<INPUT TYPE="button" NAME="d" VALUE="25" OnClick="a_plus_d(this.form)" class="ChipD">
<INPUT TYPE="button" NAME="e" VALUE="100" OnClick="a_plus_e(this.form)" class="ChipE">
<INPUT TYPE="button" NAME="f" VALUE="500" OnCLick="a_plus_f(this.form)" class="ChipF">
<INPUT TYPE="button" NAME="g" VALUE="1000" OnClick="a_plus_g(this.form)" class="ChipG">
<INPUT TYPE="button" NAME="h" VALUE="5000" OnClick="a_plus_h(this.form)" class="ChipH">
</td>
</tr>
</TABLE>
</FORM>
我开始了一个 jsfiddle:http: //jsfiddle.net/bigfatdesigns/eSAPk/