表单全部置空 你先设置select一个空值 然后在点击重置按钮时用JavaScript将这个空值赋给select 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select 置空 应该把里面的option去掉吧。 reset 只是单击后将重置表单控件为其默认值。如果 select 滴默认状态是选中,那么 reset 后会恢复选中状态,除非增加自定义脚本。<!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> <title> new document </title> <meta name="generator" content="editplus" /> <meta name="author" content="" /> <meta name="keywords" content="" /> <meta name="description" content="" /> </head> <body> <form name="form1"> <select id="sel1" size="6" multiple> <option value="2008">2008</option> <option value="2009">2009</option> <option value="2010">2010</option> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> <option value="2014">2014</option> <option value="2015">2015</option> </select> <select id="sel2" size="6" multiple> <option value="2008" selected>2008</option> <option value="2009" selected>2009</option> <option value="2010">2010</option> <option value="2011" selected>2011</option> <option value="2012">2012</option> <option value="2013">2013</option> <option value="2014">2014</option> <option value="2015">2015</option> </select> <input type="reset" /> <input type="button" id="btnReset" value="reset" /> </form> </body> <script type="text/javascript"> <!--function $(sId){ return document.getElementById(sId);}$("btnReset").onclick = function() { var oForm = document.forms("form1"); oForm.reset(); var collSel = oForm.getElementsByTagName("select"); for (var i=0; i<collSel.length; i++) { collSel[i].selectedIndex = -1; }}; //--> </script></html> 像这种小应用. 就自己写个JS置空吧...select.options[index].selected="selected"; function clearSelect(selectId){ var options=document.getElementById(selectId).options; for(var index=options.length-1;index>=0;index--){ options.remove(index); }}你试试 不用删除!新增一个<option value="" selected="selected">请选择</option>不简单么? 你说滴是左右推送滴那种 select 吧,除非页面加载时用 js 保存 select 选项备份,否则 reset 也没辙,哈我看还是回 sever 刷一下算了 jQuery复选框问题 留言板问题 js类的方法调用问题!!急 关于javascript写cookie的一个简单问题 js对象方法调用的问题!超难理解 求类似于OA的...JS setInterva导致out of memory问题 一段jquery的程序没法显示效果 swfupload怎么覆盖相同的文件 请问怎样在客户端打开一个文件夹对话框。 js 作用域的问题 JS 给表添加行
如果 select 滴默认状态是选中,那么 reset 后会恢复选中状态,
除非增加自定义脚本。
<!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>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head> <body>
<form name="form1">
<select id="sel1" size="6" multiple>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
<option value="2011">2011</option>
<option value="2012">2012</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
</select>
<select id="sel2" size="6" multiple>
<option value="2008" selected>2008</option>
<option value="2009" selected>2009</option>
<option value="2010">2010</option>
<option value="2011" selected>2011</option>
<option value="2012">2012</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
</select>
<input type="reset" />
<input type="button" id="btnReset" value="reset" />
</form>
</body>
<script type="text/javascript">
<!--
function $(sId)
{
return document.getElementById(sId);
}
$("btnReset").onclick = function() {
var oForm = document.forms("form1");
oForm.reset();
var collSel = oForm.getElementsByTagName("select");
for (var i=0; i<collSel.length; i++)
{
collSel[i].selectedIndex = -1;
}
};
//-->
</script>
</html>
就自己写个JS置空吧...
select.options[index].selected="selected";
function clearSelect(selectId){
var options=document.getElementById(selectId).options;
for(var index=options.length-1;index>=0;index--){
options.remove(index);
}
}你试试
否则 reset 也没辙,哈
我看还是回 sever 刷一下算了