<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>onkeyup的用法,及案例</title>
<script type="text/javascript">
<!--
function getneedmoney(theusernum,prc,resultid){
var usernum=parseInt(theusernum.value);
var tmptotalprc=usernum*prc;
if(usernum>=10&&usernum<20){
tmptotalprc=tmptotalprc*9/10;
}else if(usernum>=20&&usernum<30){
tmptotalprc=tmptotalprc*8/10;
}else if(usernum>=30&&usernum<50){
tmptotalprc=tmptotalprc*7/10;
}else if(usernum>=50&&usernum<100){
tmptotalprc=tmptotalprc*6/10;
}else if(usernum>=100){
tmptotalprc=tmptotalprc*5/10;
}else{
tmptotalprc=tmptotalprc;
}
document.getElementById(resultid).innerHTML=tmptotalprc;
}
//-->
</script>
</head>
<body>
<form name="emailfrm" action="eml_frm.asp" method="get">
<div id="mail_gg">
<table width="70%" height="34" border="0" cellspacing="0" cellpadding="0" style="_height:auto">
<tr>
<td width="23%" align="right">需要输入的数字</td>
<td width="16%" align="center"><input id="usernum100" name="usernum" type="text" class="num_input" maxlength="4" value="5" onkeyup="javascript: getneedmoney(this,100,'needmoney100')" /></td>
<td width="11%">个</td>
<td width="28%"><b>= <span id="needmoney100">100</span></b>元/年</td>
</tr>
</table>
</div>
</form>
</body>
</html>
loading