Select与input hidden联合的问题

mint 2005-11-14 10:09:51
我在网页中使用了
<input type="hidden" name="GetAll" id="GetAll">
<select name="_ctl0:AdminContent:AddMusic2_11:lstbSingers" size="4" id="_ctl0_AdminContent_AddMusic2_11_lstbSingers">

</select>

然后,我按一个按钮就执行添加代码:
把select中加上<option>其value为xx,显示的text为yyyy
同时把'xx,yy;'加到<input>中,以便在服务器端处理
现在的问题是,我添加容易.如何点select框中的选项,然后点删除按钮就能删除从select和input中删除选择呢?
js不熟悉,请帮助!
...全文
206 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
redtank2005 2005-11-14
  • 打赏
  • 举报
回复
删除+修改hidden
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>


<SCRIPT language=JavaScript>
function del(){
var aaa = document.forms[0].input1.value ;
var bbb = document.forms[0].select1.value ;
var ccc = document.all.select1.options[document.all.select1.selectedIndex].text ;
var ddd= bbb+','+ccc+';' ;
var eee = aaa.replace(ddd,"");
//alert(eee);
document.forms[0].input1.value = eee ;
//alert(document.forms[0].input1.value);

}
</script>
<body>
<form name="form1" method="post" action="">
<select name="select1">
<option value="111">111</option>
<option value="222">222</option>
<option value="333">333</option>
<option value="444">444</option>
</select>
<input type="button" name="Submit" value="删除" onClick="del();document.all('select1').options.remove(document.forms[0].select1.selectedIndex);">
<input name="input1" type="hidden" id="input1" value="111,111;222,222;333,333;444,444;">
</form>
</body>
</html>
redtank2005 2005-11-14
  • 打赏
  • 举报
回复
删除:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>


<body>
<form name="form1" method="post" action="">
<select name="select1">
<option value="111">111</option>
<option value="222">222</option>
<option value="333">333</option>
<option value="444">444</option>
</select>
<input type="button" name="Submit" value="删除" onClick="document.all('select1').options.remove(document.forms[0].select1.selectedIndex);">
</form>
</body>
</html>
hbhbhbhbhb1021 2005-11-14
  • 打赏
  • 举报
回复
<select name=select1>
<option value="1">文本1</option>
<option value="2">文本2</option>
<option value="3">文本3</option>
<option value="4">文本4</option>
</select>
<input name=haha2>
<input name=button value="添加" onclick=tian() type=button>
<script language=javascript>
function tian()
{
document.all.haha2.value=document.all.select1.value+","+document.all.select1.options[document.all.select1.selectedIndex].text;
}
</script>

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧