js select

来源:互联网 发布:sql找出重复数据 编辑:程序博客网 时间:2024/06/05 23:40
<!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>无标题文档</title>
<script type="text/javascript">
   function getTest(){
 
      var obj=document.getElementById("t1");
      //alert(obj);
    var index=obj.selectedIndex;
    // alert(index);
    
    var text=obj.options[index].text;
    alert(text);
    var value=obj.options[index].value;
    alert(value);
    
    
   }
   
    
    
</script>
</head>

<body>
    <select id="t1" name="jobname"  onchange="getTest();">
       <option value="China">中国</option>
       <option value="USA">美国</option>
       <option value="English">英国</option>
    </select>
    
</body>
</html>
0 0
原创粉丝点击