带提示的下拉框

来源:互联网 发布:章鱼直播软件下载 编辑:程序博客网 时间:2024/05/21 09:15
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  
<head>
    
<title>测试js</title>
    
    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    
<meta http-equiv="description" content="this is my page">
    
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    
<script type="text/javascript" language="javascript">
    
var selIndex;
    
function indx(){
        selIndex
=document.getElementById('list1').options.selectedIndex;
    }

    
function chk(val){
    
var selIndex2=document.getElementById('list1').selectedIndex;
           
if(confirm('你真的要选择'+val)){
        document.getElementById(
'list1').options[selIndex2].selected='selected';
        selIndex
=selIndex2;
            
return true;
        }
else{
            document.getElementById(
'list1').options[selIndex].selected='selected';
        }

    }

     
</script>
  
</head>
  
  
<body onLoad="indx()"> 
  

<form method="get" >
<select size="1" name="list1"  id="list1" onChange="chk(this.options[this.options.selectedIndex].text)">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</form> 

  
</body>
</html> 
 
原创粉丝点击