主题:求解问题啊!!
这段代码怎么不可以实现功能啊:功能就是,你输入一个值,当你选择平方就计算他的平方,选择倍数是就计算倍数;
<html>
<head>
<script language="Javascript">
function c1(form,callingField)
{ if(callingField=="result")
if(from.action[1].checked)
{ from.entry.value=Math.sqrt(from.result.value)}
else
{ from.entry.value=from.result.value/2; }
else
{ if(from.action[1].checked)
{ from.result.value=from.entry.value*from.entry.value }
else { from.result.value=from.entry.value*2}
}
}
</script>
</head>
<body>
<form method=post>
请输入一个值:<br>
<input type="text" name="entry" value=0 conChange="c1(this.from,this.name)" ;><p>
请选择加倍:<br>
<input type="radio" name="action" value="加倍" onClick="c1(this.from,this.name)";><p>
请选择平方:<br>
<input type="radio" name="action" value="平方" onClick="c1(this.from,this.name)";><p>
结果为:<br>
<input type="text" name="result" value="0" onchange="c1(this.from,this.name)";>
</from>
</body>
</html>
<html>
<head>
<script language="Javascript">
function c1(form,callingField)
{ if(callingField=="result")
if(from.action[1].checked)
{ from.entry.value=Math.sqrt(from.result.value)}
else
{ from.entry.value=from.result.value/2; }
else
{ if(from.action[1].checked)
{ from.result.value=from.entry.value*from.entry.value }
else { from.result.value=from.entry.value*2}
}
}
</script>
</head>
<body>
<form method=post>
请输入一个值:<br>
<input type="text" name="entry" value=0 conChange="c1(this.from,this.name)" ;><p>
请选择加倍:<br>
<input type="radio" name="action" value="加倍" onClick="c1(this.from,this.name)";><p>
请选择平方:<br>
<input type="radio" name="action" value="平方" onClick="c1(this.from,this.name)";><p>
结果为:<br>
<input type="text" name="result" value="0" onchange="c1(this.from,this.name)";>
</from>
</body>
</html>