日期:2014-05-16 浏览次数:20383 次
function calc() { var value1 = parseInt(document.getElementById("Full").value); var value2 = value1*100+100 ; var value3 = value2*0.9 ; document.getElementById("News").value=value2; document.getElementById("practical").value=value3; }
------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<script type="text/javascript">
function countVal(val){
//var fullVal = parseInt(val);//转换为int
var fullVal = parseFloat(val);//转换为float
document.getElementById('News').value = (fullVal * 100) + 100;
document.getElementById('practical').value = (document.getElementById('News').value * 90)/100;
}
</script>
<body>
<table>
<tr>
<td>
<input type="text" style="width:60px" id="Full" onkeyup="countVal(this.value);" /> × <input type="button" value="百分点"/> + <input type="button" value="100"/> = <input id="News" type="text" style="width:60px;margin-right:60px"/> 实际:<input id="practical" type="text" style="width:60px"/>
</td>
</tr>
</table>
</body>
</html>