
ASP表单判断显示代码怎么写
有一个文本框一个下拉框【普卡会员卡】当文本框里输入0-4999的数值的时候下拉框里边会自动变成普卡的选项如果输入5000以上下拉框里会自动变成会员卡的选项...
有一个文本框 一个下拉框【普卡 会员卡】 当文本框里输入0-4999的数值的时候 下拉框里边 会自动变成普卡的选项 如果输入 5000以上 下拉框里会自动变成 会员卡的选项
展开
3个回答
展开全部
这个简单
<input id="txt1" onpropertychange="javascript:dochg()" />
<select id="sel1" >
<option value="1">普卡</option>
<option value="2">会员卡</option>
</select>
<script language="javascript">
<!--
function dochg(){
var mv=0;
mv=document.getElementById("txt1").value;
if(mv<5000){
document.getElementById("sel1").options[0].selected=true;
}
else
{
document.getElementById("sel1").options[1].selected=true;
}
}
//-->
</script>
<input id="txt1" onpropertychange="javascript:dochg()" />
<select id="sel1" >
<option value="1">普卡</option>
<option value="2">会员卡</option>
</select>
<script language="javascript">
<!--
function dochg(){
var mv=0;
mv=document.getElementById("txt1").value;
if(mv<5000){
document.getElementById("sel1").options[0].selected=true;
}
else
{
document.getElementById("sel1").options[1].selected=true;
}
}
//-->
</script>
展开全部
连是不是数字都给你判断了
<!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=utf-8" />
<title>无标题文档</title>
<script language="javascript">
function chk(str){
if(str==""){
alert("对不起,请输入数字!");
return false;
}
var selects =document.getElementById("select");
if(checkRate(str)==true){
if(checkRate(str)==true){
if(str <=4999){
selects.selectedIndex=0;
}else{
selects.selectedIndex=1;
}
}
}
}
function checkRate(input)
{
var re = /^[1-9]+[0-9]*]*$/
if (!re.test(input))
{
alert("请输入数字(例:20000)");
return false;
}
return true;
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<input type="text" name="textfield" id="textfield" onblur="chk(this.value);"/>
<select name="select" id="select">
<option>普卡</option>
<option>会员卡</option>
</select>
</form>
</body>
</html>
<!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=utf-8" />
<title>无标题文档</title>
<script language="javascript">
function chk(str){
if(str==""){
alert("对不起,请输入数字!");
return false;
}
var selects =document.getElementById("select");
if(checkRate(str)==true){
if(checkRate(str)==true){
if(str <=4999){
selects.selectedIndex=0;
}else{
selects.selectedIndex=1;
}
}
}
}
function checkRate(input)
{
var re = /^[1-9]+[0-9]*]*$/
if (!re.test(input))
{
alert("请输入数字(例:20000)");
return false;
}
return true;
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<input type="text" name="textfield" id="textfield" onblur="chk(this.value);"/>
<select name="select" id="select">
<option>普卡</option>
<option>会员卡</option>
</select>
</form>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
LS正解
但是onblur改为onkeydown,效果更好了,onkeydown直接在输入的时候就能变换了
但是onblur改为onkeydown,效果更好了,onkeydown直接在输入的时候就能变换了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询