道非道 非常道

勤思、谨言、慎行、厚积、薄发

统计

web

天圆

经济 政治 军事

键康

html select 另类用法

<html>
<head>
<script language="javascript">
function number(){
var obj = document.getElementById("mySelect");
/*
for(var i=0;i<obj.options.length;i++){

    if(obj.options[i].value=='我的包包'){
        obj.selectedIndex = i;
    }
}
*/
obj.value='我的包包';
//obj.options[obj.selectedIndex] = Option("我的吃吃","4");//在当前选中的那个的值中改变
//obj.selectedIndex = 3;
//obj.options.add(new Option("我的吃吃","4"));//再添加一个option
//alert(obj.selectedIndex);//显示序号,option自己设置的
//obj.options[obj.selectedIndex].text = "我的吃吃";//更改值
//obj.remove(obj.selectedIndex);//删除功能
}
</script>
</head>
<body>
<select id="mySelect">
<option value="我的包包">我的包包</option>
<option value="我的本本">我的本本</option>
<option value="我的油油">我的油油</option>
<option value="我的担子">我的担子</option>
</select>
<input type="button" name="button" value="查看结果" onclick="number();">
</body>
</html>

/*
 *  使下拉列表的内容与选定的条件相符    
 */
function chooseSelect(id,value){
    var select = document.getElementById(id);
    var options = select.options;
    // 循环变量,找到适合的数值
    for (var i = 0; i < options.length; i += 1) {
        if(options[i].value == value){
            options[i].selected = true;
        }
    }

}





posted on 2008-12-12 18:34 星期五 阅读(477) 评论(0)  编辑  收藏 所属分类: web 开发


只有注册用户登录后才能发表评论。


网站导航: