得到下拉框的值 赋给另外一个下拉框
发布网友
发布时间:2022-04-19 06:51
我来回答
共4个回答
热心网友
时间:2022-04-19 08:20
<!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 language="javascript">
<!--
function selectInda(sele_id,add_id)
{
var frm = document.getElementById(sele_id);
var bjm = document.getElementById(add_id);
var oi = bjm.options.length
if(frm.value!="")
{
if(oi==0)
{
bjm.options[oi] = new Option(frm.options[frm.selectedIndex].text,frm.value);
}
else if(oi==1)
{
if(bjm.options[oi-1].value!=frm.value) {
bjm.options[oi] = new Option(frm.options[frm.selectedIndex].text,frm.value);
}
}
else if(oi>1)
{
var sign=0;
for(var a=0;a<oi;a++) {
if(frm.value==bjm.options[a].value) {sign = sign+1;}
}
if(sign==0) {
bjm.options[oi] = new Option(frm.options[frm.selectedIndex].text,frm.value);
}
}
}
}
function deleteIndex(dele_id)
{
var frm = document.getElementById(dele_id);
var fln = frm.options.length;
if(frm.value!="")
{
frm.options.removeChild(frm.options[frm.selectedIndex]);
}
}
function subIndex(subid, questid)
{
var Sobj = document.getElementById(subid);
var Qobj = document.getElementById(questid);
if(Sobj.options.length!=0)
{
Qobj.value = "";
for(var b=0;b<Sobj.options.length;b++)
{
if(b!=0) {Qobj.value += "," + Sobj.options[b].value;}
else {Qobj.value += Sobj.options[b].value;}
}
}
else
{
Qobj.value = "";
}
}
//-->
</script>
</head>
<body>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="2" bgcolor="#CCCCCC">
<tr>
<td> </td>
<td><table width="500" border="0" align="center" cellpadding="0" cellspacing="0" id="groupgoods-table" style="display:">
<tr>
<th height="25" bgcolor="#CCCCCC">可选</th>
<th bgcolor="#CCCCCC">操作</th>
<th bgcolor="#CCCCCC">已选</th>
</tr>
<tr>
<td width="42%"><select name="about_select1" size="20" id="about_select1" style="width:100%" ondblclick="selectInda('about_select1','about_option1');subIndex('about_option1', 'about_fitg');">
<option value="1">linghunts@163.com</option>
<option value="2">huangxl@chinaok.com.cn</option>
<option value="3">a8235145@163.com</option>
<option value="4">ahuangyo@sina.com</option>
<option value="5">linghunbaobei@163.com</option>
</select></td>
<td align="center"><p>
<input name="left_add1" type="button" class="button" id="left_add1" value="添加>" onclick="selectInda('about_select1','about_option1');subIndex('about_option1', 'about_fitg');" />
</p>
<p>
<input name="right_del1" type="button" class="button" id="right_del1" value="<删除" onclick="deleteIndex('about_option1');subIndex('about_option1', 'about_fitg');" />
</p>
<p>
<input name="right_delall" type="button" class="button" id="right_delall" value="<<" onclick="document.getElementById('about_option1').options.length=0;document.getElementById('about_fitg').value='';" />
</p></td>
<td width="42%"><select name="about_option1" size="20" multiple="multiple" id="about_option1" style="width:100%" ondblclick="deleteIndex('about_option1');subIndex('about_option1', 'about_fitg');">
</select>
<input name="about_fitg" id="about_fitg" type="hidden" value="" /></td>
</tr>
</table></td>
<td> </td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
</table>
</body>
</html>
参考资料:http://hi.baidu.com/addgrrr/blog/item/9f26de013eea7dd5277fb5c4.html
热心网友
时间:2022-04-19 09:38
<select name="select1" onchange="changeSelecte2value();">
<option>1111</option>
<option>2222</option>
</select>
<select id="select2">
<option>1111</option>
<option>2222</option>
</select>
-----------------------------------
function changeSelecte2value(){
document.getElementById("select2").value = document.getElementById("select1").value;
}
热心网友
时间:2022-04-19 11:13
是只复制选中的还是复制全部这个下拉选项的内容
热心网友
时间:2022-04-19 13:04
//描述: 添加不重复列表框元素
function selAdd( srcList, dstList )
{
var selectedIndex = new Array();
var count = 0;
for ( i=0; i<srcList.options.length; i++ ){
if ( srcList.options[i].selected ){
selectedIndex[count] = i;
count ++;
}
}
for ( j=0; j<selectedIndex.length; j++ ){
k = selectedIndex[j];
if ( chkDup( srcList.options[k].value, dstList )==false ){
dstList.options.length++;
var len = dstList.options.length-1;
dstList.options[len].value = srcList.options[k].value;
dstList.options[len].text = srcList.options[k].text;
}
}
}
//描述: 检测列表框元素重复
function chkDup( item, list )
{
for ( i=0; i<list.options.length; i++ ){
//alert( item + " - " + list.options[i].value );
if ( item == list.options[i].value ){
return true;
}
}
return false;
}