望大虾来完善一下100分欢迎参与 运行了你的程序不太清楚你要表达什么这个东西bug一大堆!1:选项编号自增2:前2个删除不掉3:单选多选不知道啥意思4:下拉列表不知道什么意思5:后面的选择一嘛意思6:怎么提交? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 额...真的照用了...真的很多BUG的... 嗯 BUG是有 就是那序号的问题单选多选不用考虑下拉列表就是最多选择多少项的意思,增加一项就下拉列表也多一项后面的选择 呵呵 是我CSS调试下 这个没有用提交 不用的就是添加删除 和下拉列表正常就可以了 LZ,我献丑了<!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><style type="text/css">.optiontxt{width:70px;background:#ccc; display:inline-block;}.contenttxt{width:180px; background:#FF0000;display:inline-block;}</style><script type="text/javascript">function add(num){document.getElementById('polloption').innerHTML="";for(i=1;i<=num;i++){var objchoice=document.createElement("label"); objchoice.sx=i; objchoice.innerHTML="<span class=\"optiontxt\">选项"+i+":</span><span class=\"contenttxt\"><input maxlength=\"50\" name=\"choices\" type=\"text\" /></span><span style=\"cursor: pointer;\" onclick=\"del("+i+")\">删除</span><br>" document.getElementById("polloption").appendChild(objchoice); var opt=new Option('最多选'+i+'项',i); document.getElementById("maxselect").options[i]=opt; document.getElementById("maxselect").options[i].selected=true;}}function del(sx){var list = document.getElementsByTagName("label"); for(var n=0,j=1;n<list.length;n++){ var el = list[n]; if(el.sx==sx){ if(n<2){alert("至少需要两个选项!");return false;} else{ el.parentNode.removeChild(el); n--; document.getElementById("maxselect").options[list.length+1]=null; document.getElementById("maxselect").options[list.length].selected=true; } } else{ el.getElementsByTagName("span")[0].innerHTML = "选项"+(j++)+":"; } }}</script></head><body><div id="polloption"></div><div><a href="javascript: void(0);" onclick="add(document.getElementById('polloption').getElementsByTagName('input').length+1);">+添加一项</a></div><div>投票方式:<input name="polltype" type="radio" value="" />单选 <input name="polltype" type="radio" value="" />多选 <select id="maxselect" name="maxselect"><option value="">请选择...</option></select></div><script type="text/javascript">add(3);</script><span class="optiontxt">选项1:</span><span class="contenttxt"><input type="text" /></span></body></html> <!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=utf-8" /><title>添加删除项【投票】</title><!--style type="text/css">.optiontxt{width:70px;background:#ccc; display:inline-block;}.contenttxt{width:180px; background:#FF0000;display:inline-block;}</style--><script type="text/javascript">function add(){ var i = document.getElementsByTagName("label").length+1; var objchoice=document.createElement("label"); objchoice.sx=i; objchoice.innerHTML="<span class=\"optiontxt\">选项"+i+":</span><span class=\"contenttxt\"><input maxlength=\"50\" name=\"choices\" type=\"text\" /></span><span style=\"cursor: pointer;\" onclick=\"del(this.parentElement.sx)\">删除</span><br>" document.getElementById("polloption").appendChild(objchoice); resetOpt();}function del(sx){ var list = document.getElementsByTagName("label"); if(list.length<=2){ alert("至少需要两个选项!"); return false; } for(var n=0,j=1;n<list.length;n++){ var el = list[n]; if(el.sx==sx){ el.parentNode.removeChild(el); n--; document.getElementById("maxselect").options[j]=null; document.getElementById("maxselect").options[n+1].selected=true; }else{ el.sx=j; el.getElementsByTagName("span")[0].innerHTML = "选项"+(j++)+":"; } } resetOpt();}function resetOpt(){ var opts = document.getElementById("maxselect").options; var l = document.getElementsByTagName("label").length; opts.length = 0; for(var i=1; i<l+1; i++){ var opt=new Option('最多选'+i+'项',i); document.getElementById("maxselect").options[i]=opt; } document.getElementById("maxselect").options[l].selected=true;}</script></head><body><div id="polloption"></div><div><a href="javascript: void(0);" onclick="add();">+添加一项</a></div><div>投票方式:<input name="polltype" type="radio" value="" />单选 <input name="polltype" type="radio" value="" />多选 <select id="maxselect" name="maxselect"><option value="">请选择...</option></select></div><script type="text/javascript">for(var k=1;k<4;k++){add(k);}</script></body></html>还有什么BUG的话我不保证..不过比你那个好... 完善alert("至少需要两个选项!")这个问题<!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><style type="text/css">.optiontxt{width:70px;background:#ccc; display:inline-block;}.contenttxt{width:180px; background:#FF0000;display:inline-block;}</style><script type="text/javascript">function add(num){document.getElementById('polloption').innerHTML="";for(i=1;i<=num;i++){var objchoice=document.createElement("label"); objchoice.sx=i; objchoice.innerHTML="<span class=\"optiontxt\">选项"+i+":</span><span class=\"contenttxt\"><input maxlength=\"50\" name=\"choices\" type=\"text\" /></span><span style=\"cursor: pointer;\" onclick=\"del("+i+")\">删除</span><br>" document.getElementById("polloption").appendChild(objchoice); var opt=new Option('最多选'+i+'项',i); document.getElementById("maxselect").options[i]=opt; document.getElementById("maxselect").options[i].selected=true;}}function del(sx){var list = document.getElementsByTagName("label"); for(var n=0,j=1;n<list.length;n++){ var el = list[n]; if(el.sx==sx){ if(document.getElementById('polloption').getElementsByTagName('input').length<3){alert("至少需要两个选项!");return false;} else{ el.parentNode.removeChild(el); n--; document.getElementById("maxselect").options[list.length+1]=null; document.getElementById("maxselect").options[list.length].selected=true; } } else{ el.getElementsByTagName("span")[0].innerHTML = "选项"+(j++)+":"; } }}</script></head><body><div id="polloption"></div><div><a href="javascript: void(0);" onclick="add(document.getElementById('polloption').getElementsByTagName('input').length+1);">+添加一项</a></div><div>投票方式:<input name="polltype" type="radio" value="" />单选 <input name="polltype" type="radio" value="" />多选 <select id="maxselect" name="maxselect"><option value="">请选择...</option></select></div><script type="text/javascript">add(3);</script><span class="optiontxt">选项1:</span><span class="contenttxt"><input type="text" /></span></body></html> Extjs4.0 datefield 问题 正则表达式修饰符y Array二维数组问题 求助一个JS, 内层Table样式问题,请高手赐教 如何让长字符串输出的时候自动换行呢? 高分求助 VBScript和JavaScript中从一个站点下载文件并执行的语句是什么? JAVASCRIPT中的checkbox数据如何传送与接收的? 怎样才能在网页中调用打开.exe文件 鼠标点击事件问题 一个关于htm页面中的JavaScript解密的问题。如何解密 一个图片轮播脚本问题javascript
单选多选不用考虑
下拉列表就是最多选择多少项的意思,增加一项就下拉列表也多一项
后面的选择 呵呵 是我CSS调试下 这个没有用
提交 不用的
就是添加删除 和下拉列表正常就可以了
LZ,我献丑了<!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>
<style type="text/css">
.optiontxt{width:70px;background:#ccc; display:inline-block;}
.contenttxt{width:180px; background:#FF0000;display:inline-block;}
</style>
<script type="text/javascript">
function add(num){
document.getElementById('polloption').innerHTML="";
for(i=1;i<=num;i++){
var objchoice=document.createElement("label");
objchoice.sx=i;
objchoice.innerHTML="<span class=\"optiontxt\">选项"+i+":</span><span class=\"contenttxt\"><input maxlength=\"50\" name=\"choices\" type=\"text\" /></span><span style=\"cursor: pointer;\" onclick=\"del("+i+")\">删除</span><br>"
document.getElementById("polloption").appendChild(objchoice);
var opt=new Option('最多选'+i+'项',i);
document.getElementById("maxselect").options[i]=opt;
document.getElementById("maxselect").options[i].selected=true;
}
}
function del(sx){
var list = document.getElementsByTagName("label");
for(var n=0,j=1;n<list.length;n++){
var el = list[n];
if(el.sx==sx){
if(n<2){alert("至少需要两个选项!");return false;}
else{
el.parentNode.removeChild(el);
n--;
document.getElementById("maxselect").options[list.length+1]=null;
document.getElementById("maxselect").options[list.length].selected=true;
}
}
else{
el.getElementsByTagName("span")[0].innerHTML = "选项"+(j++)+":";
}
}
}
</script></head><body>
<div id="polloption"></div>
<div><a href="javascript: void(0);" onclick="add(document.getElementById('polloption').getElementsByTagName('input').length+1);">+添加一项</a></div>
<div>投票方式:<input name="polltype" type="radio" value="" />单选 <input name="polltype" type="radio" value="" />多选
<select id="maxselect" name="maxselect"><option value="">请选择...</option></select></div>
<script type="text/javascript">
add(3);
</script><span class="optiontxt">选项1:</span><span class="contenttxt"><input type="text" /></span>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加删除项【投票】</title>
<!--style type="text/css">
.optiontxt{width:70px;background:#ccc; display:inline-block;}
.contenttxt{width:180px; background:#FF0000;display:inline-block;}
</style-->
<script type="text/javascript">
function add(){
var i = document.getElementsByTagName("label").length+1;
var objchoice=document.createElement("label");
objchoice.sx=i;
objchoice.innerHTML="<span class=\"optiontxt\">选项"+i+":</span><span class=\"contenttxt\"><input maxlength=\"50\" name=\"choices\" type=\"text\" /></span><span style=\"cursor: pointer;\" onclick=\"del(this.parentElement.sx)\">删除</span><br>"
document.getElementById("polloption").appendChild(objchoice);
resetOpt();
}
function del(sx){
var list = document.getElementsByTagName("label");
if(list.length<=2){
alert("至少需要两个选项!");
return false;
}
for(var n=0,j=1;n<list.length;n++){
var el = list[n];
if(el.sx==sx){
el.parentNode.removeChild(el);
n--;
document.getElementById("maxselect").options[j]=null;
document.getElementById("maxselect").options[n+1].selected=true;
}else{
el.sx=j;
el.getElementsByTagName("span")[0].innerHTML = "选项"+(j++)+":";
}
}
resetOpt();
}
function resetOpt(){
var opts = document.getElementById("maxselect").options;
var l = document.getElementsByTagName("label").length;
opts.length = 0;
for(var i=1; i<l+1; i++){
var opt=new Option('最多选'+i+'项',i);
document.getElementById("maxselect").options[i]=opt;
}
document.getElementById("maxselect").options[l].selected=true;
}
</script></head><body>
<div id="polloption"></div>
<div><a href="javascript: void(0);" onclick="add();">+添加一项</a></div>
<div>投票方式:<input name="polltype" type="radio" value="" />单选 <input name="polltype" type="radio" value="" />多选
<select id="maxselect" name="maxselect"><option value="">请选择...</option></select></div>
<script type="text/javascript">
for(var k=1;k<4;k++){add(k);}
</script>
</body>
</html>还有什么BUG的话我不保证..不过比你那个好...
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>添加删除项【投票】</title>
<style type="text/css">
.optiontxt{width:70px;background:#ccc; display:inline-block;}
.contenttxt{width:180px; background:#FF0000;display:inline-block;}
</style>
<script type="text/javascript">
function add(num){
document.getElementById('polloption').innerHTML="";
for(i=1;i<=num;i++){
var objchoice=document.createElement("label");
objchoice.sx=i;
objchoice.innerHTML="<span class=\"optiontxt\">选项"+i+":</span><span class=\"contenttxt\"><input maxlength=\"50\" name=\"choices\" type=\"text\" /></span><span style=\"cursor: pointer;\" onclick=\"del("+i+")\">删除</span><br>"
document.getElementById("polloption").appendChild(objchoice);
var opt=new Option('最多选'+i+'项',i);
document.getElementById("maxselect").options[i]=opt;
document.getElementById("maxselect").options[i].selected=true;
}
}
function del(sx){
var list = document.getElementsByTagName("label");
for(var n=0,j=1;n<list.length;n++){
var el = list[n];
if(el.sx==sx){
if(document.getElementById('polloption').getElementsByTagName('input').length<3){alert("至少需要两个选项!");return false;}
else{
el.parentNode.removeChild(el);
n--;
document.getElementById("maxselect").options[list.length+1]=null;
document.getElementById("maxselect").options[list.length].selected=true;
}
}
else{
el.getElementsByTagName("span")[0].innerHTML = "选项"+(j++)+":";
}
}
}
</script></head><body>
<div id="polloption"></div>
<div><a href="javascript: void(0);" onclick="add(document.getElementById('polloption').getElementsByTagName('input').length+1);">+添加一项</a></div>
<div>投票方式:<input name="polltype" type="radio" value="" />单选 <input name="polltype" type="radio" value="" />多选
<select id="maxselect" name="maxselect"><option value="">请选择...</option></select></div>
<script type="text/javascript">
add(3);
</script><span class="optiontxt">选项1:</span><span class="contenttxt"><input type="text" /></span>
</body>
</html>