js select 增加option
2014-07-15 10:08
323 查看
<!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 array=[1,2,3];
var options="";
for(var i in array){
options+="<option value="+array[i]+">"+array[i]+"</option>\n";
// alert(options);
}
document.getElementById("t1").innerHTML=options;
}
</script>
</head>
<body>
<select id="t1" name="t1" onclick="getTest()">
</select>
</body>
</html>
<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 array=[1,2,3];
var options="";
for(var i in array){
options+="<option value="+array[i]+">"+array[i]+"</option>\n";
// alert(options);
}
document.getElementById("t1").innerHTML=options;
}
</script>
</head>
<body>
<select id="t1" name="t1" onclick="getTest()">
</select>
</body>
</html>
相关文章推荐
- 使用js 在IE和火狐firfox 里动态增加select 的option
- JS两种增加SELECT 下的option方法
- js 动态 增加 删除 select 子项 option
- js 动态 增加 删除 select 子项 option
- 给select下拉框增加option发现的问题,以及js怎么设置中断
- 使用js 在IE和火狐firfox 里动态增加select 的option
- js 操作select和option(转载)
- DWR util.js 整理(DWR 处理各种form表单Select/option,table等,List,Bean
- DWR util.js 整理(DWR 处理各种form表单Select/option,table等,List,Bean
- DWR util.js 整理(DWR 处理各种form表单Select/option,table等,List,Bean
- 利用js给select添加option并选中该option
- DWR util.js 整理(DWR 处理各种form表单Select/option,table等
- JS动态添加与删除select中的Option对象
- js动态增加、插入、修改、删除option
- IE下 JS添加Select元素的option问题
- js为select动态添加option,使用webservice提供数据
- js select 隐藏option
- 在javascript中增加select控件的Option选项
- 通过js增加select的值
- JS动态改变select选择变更option的index值