<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script language="JavaScript">
<!--
function test()
{ var o = new Option("text","value");

var s = document.all.aa; s.add(o);
}
function test1()
{
var s = document.all.aa; if(s.options.length>0)
{
alert(s.options[0].value);
}
}
//-->
</script>
</head><body>
<select name="" id = "aa"></select><input type=button value=click onclick="test()");><input type=button value=displayvalue onclick="test1()");>
</body>
</html>

解决方案 »

  1.   

    比如SELECT里面都是人名,text显示时显示名字,value对应相应人的编号
      

  2.   

    value值非常方便,当要显示和实际要得到的值不同的时候,value值就会变的非常有用。
      

  3.   

    <select id="select">
     <option value="值在这里">文字放这里</option>
    </select>
      

  4.   

    B.22 options数组
      该数组是select对象的一个属性,即选择框中的所有选项(<OPTION>)的一个列表。
      属性
      defaultSelected 选项列表中的缺省选项
      index 选项列表中某选项的索引位置
      length 选项列表中的选项数(<OPTIONS>)
      name 选项列表的名字(NAME特性)
      selected 表示选项列表中某选项<OPTION>是否被选中的一个布尔类型值
      selectedIndex 选项列表中已选中的<OPTION>的索引(位置)
      text 选项列表中<OPTION>标记后的文本
      value 选项列表中的VALUE=特性