分享

JavaScript将数组数据添加到Select下拉框中

 岑经沧海难为水 2014-08-14
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www./TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>将数组中的数据添加到下拉菜单中</title>
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
<script type="text/javascript">
var counts;
counts=0;
arr = new Array("JavaScript与ASP","JavaScript与JSP","JavaScript与ASP.NET","JavaScript与PHP");
counts=arr.length;
function Myselect(){
  var i;
  for (i=0;i < counts; i++) {
    document.form1.sel.options[i] = new Option(arr[i],i);
  }
}
</script>
</head>
<body>
<table width="280" height="160" border="0" align="center" cellpadding="5" cellspacing="0">
  <tr>
    <td height="34" align="center"><span class="style1" style="font-weight:bold ">将数组中的数据添加到下拉菜单中</span></td>
  </tr>
  <tr>
    <td align="center" valign="top" bgcolor="#9ACCFF"><form name="form1">
      <table width="235" height="69" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="21"><select name="sel" id="sel" onFocus="Myselect()">
          </select></td>
        </tr>
        <tr>
          <td height="120"> </td>
        </tr>
      </table>
    </form></td>
  </tr>
</table>
</body>
</html>

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约