您的位置:首页 > 其它

select 下拉列表相关的问题

2011-11-30 15:55 555 查看
一.下拉列表多选

例子:

select 的multiple属性可以设置该下拉框是多选或者单选。multiple="multiple"以后,按住ALT键就可以多选了。

<select id="sel1" multiple="multiple">

<option value="1">A</option>

<option value="1">B</option>

<option value="1">C</option>

<option value="1">D</option>

<option value="1">E</option>

<option value="1">F</option>

</select>

二.下拉列表可选可编辑

自定义函数: ShowToText (将列表项中的值传递给文本)

function ShowToText (){

document.form_name.textfield_name.value=document.form_name.select_name.options

[document.form_name.select_name.selectedIndex].value;

}

自定义函数:ChangeWidth (动态改变文本框和下拉列表框的宽度,num为状态切换的判断参数)

function ChangeWidth(num){

if(num==1){

eval(document.form_name.textfield_name.style.width=0);

eval(document.form_name.select_name.style.width=180);

}else{

eval(document.form_name.textfield_name.style.width=160);

eval(document.form_name.select_name.style.width=20);

}

}

<form name="form_name" >

<input type="text" name="textfield_name" style="width: 160">

<select class="combox" name="select_name" style="width: 20" onChange="ShowToText();ChangeWidth(2)"

onMouseMove="ChangeWidth(1)" onBlur="ChangeWidth(2)">

<option></option>

<option value="车载机一厂">车载机一厂</option>

<option value="车载机二厂">车载机二厂</option>

</select>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: