<!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 language="javascript">
function into(l,selectPageNo){ 
var pag=selectPageNo;
if(l!=0){
for(var i=0;i<l;i++){
 pag.options[i]=new Option((i+1),(i+1));
}
}
function intu(){ 
alert();
}
}
</script>
</head><body onload="into(5,selectPageNo)">
 <table>
  <label>
  <select name="selectPageNo" id="selectPageNo" onchange="intu()">
   
  </select>
  </label>
 </table>
</body>
</html>
我写的代码,现在想取出selectPageNo中选中的值,那位大哥指教一下。。谢谢!!

解决方案 »

  1.   


    function into(l,selectPageNo){ 
    var pag=selectPageNo; 
    if(l!=0){ 
    for(var i=0;i <l;i++){ 
    pag.options[i]=new Option((i+1),(i+1)); 


    }
    function intu(osel){ 
    alert(osel.options[osel.selectedIndex].text)
    } </script> 
      

  2.   


    <!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 language="javascript"> 
    function into(l,selectPageNo){ 
      var pag=document.getElementById(selectPageNo);
      if(l!=0){ 
        for(var i=0;i <l;i++){ 
          pag.options[pag.options.length]=new Option((i+1),(i+1)); 
        }
      }

    function intu(obj){
    var v = obj.options[obj.selectedIndex].value
       alert(v); 

    </script> 
    </head> <body onload="into(5,'selectPageNo')"> 
    <table> 
      <label> 
      <select name="selectPageNo" id="selectPageNo" onchange="intu(this)"> 
      
      </select> 
      </label> 
    </table> 
    </body> 
    </html>
      

  3.   

    这是一个我写的例子 很简单 你看看 肯定会的<html>
    <head>
    <script language="JavaScript">
        function GaiBian(osel)
        {
            alert(osel.options[osel.selectedIndex].text);
        }
    </script>
    </head>
    <body>
    <select name='selectSS' onChange="GaiBian(this)">
    <option value='1'>1 </option> 
    <option value='2'>2 </option> 
    <option value='3'>3 </option> 
    </select> 
    </body>
    </html>
    ===========
    呵呵 是不是很简单啊 记住给我加分啊