js: select一个选项包含多个值的用法

来源:互联网 发布:配乐 知乎 编辑:程序博客网 时间:2024/05/16 23:33


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language="javascript">
function testManyValue(selectObj){
 var theValue = selectObj.options[selectObj.selectedIndex].manyValue;
 alert(theValue);
}
</script>
</head>

<body>
<table width="300" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><input type="button" value="点击" onClick="testManyValue(select1)"></td>
    <td>
      <select name="select1" onChange="submitForm(this)">
        <option id="a" value="value1" manyValue="value2">values</option>
      </select>
    </td>
  </tr>
</table>
</body>
</html>