javascript如何输出计算结果?
<script language= "javascript ">
function jsq()
{
var dy=document.myform.dy.value;
var dr=document.myform.dr.value;
for (var i=0;i <myform.js.length;i++)
{
var e=myform.js[i];
if (e.checked)
js=e.value;
}
alert(dy+js+dr);//输出1+1,想让它输出1+1的和
document.myform.jg.value=Math.round(dy+js+dr);
}
</script>
<form id= "myform " name= "myform " method= "post " action= " ">
<td height= "50 " align= "center "> <input name= "dy " type= "text " id= "dy " onKeyPress= "if((event.keyCode <48 || event.keyCode> 57) && event.keyCode!=46 || /\.\d\d$/.test(value))event.returnValue=false; "/>
<input type= "radio " name= "js " value= "+ " <% if request.form( "js ")= "+ " then %> checked= "checked " <% end if %> /> +
<input name= "js " type= "radio " value= "- " <% if request.form( "js ")= "- " or request.form( "js ")= " " then %> checked= "checked " <% end if %> /> -
<input type= "radio " name= "js " value= "* " <% if request.form( "js ")= "* " then %> checked= "checked " <% end if %> /> ×
<input type= "radio " name= "js " value= "/ " <% if request.form( "js ")= "/ " then %> checked= "checked " <% end if %> /> ÷
<input name= "dr " type= "text " id= "dr " onKeyPress= "if((event.keyCode <48 || event.keyCode> 57) && event.keyCode!=46 || /\.\d\d$/.test(value))event.returnValue=false; "/>
<input type= "button " name= "Submit " value= "计算 " onClick= "jsq(); " />
=
<input name= "jg " type= "text " id= "jg " onKeyPress= "if((event.keyCode <48 || event.keyCode> 57) && event.keyCode!=46 || /\.\d\d$/.test(value))event.returnValue=false; "/> </td>
</form>
------解决方案--------------------Number(var)
转换下
如果是整形还可以parseInt(var)
------解决方案-------------------- <script language= "javascript "&g