php如何将数据库中读取的数值与网页文本框输入的数值比较(输入文本框后,不需要按钮提交),且提示大小于
1个回答
展开全部
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<input type="text" id="ipt"/>
<span id="errMsg" style=" color:red">大于</span>
<span id="errMsg2" style=" color:red">小于</span>
<div><input type="text" disabled="disable" id="totalIpt" value="取出来的值写到这里"></div>
<script type="text/javascript">
var getId = function(id){
return document.getElementById(id);
}
var ipt = getId('ipt'),
totalIpt = getId('totalIpt'),
errMsg = getId('errMsg');
errMs2g = getId('errMsg2');
errMsg.style.display = 'none';
errMsg2.style.display = 'none';
ipt.onkeyup = function(){
if(Number(this.value) > Number(totalIpt.value)){
errMsg.style.display = 'block';
}else{
errMsg.style.display = 'none';
}
if(Number(this.value) > Number(totalIpt.value)){
errMsg2.style.display = 'none';
}else{
errMsg2.style.display = 'block';
}
}
</script>
</body>
</html>
数据库取出来的值写到相应位置就OK
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询