我从一个listbox里双击某一项添加到另外一个listbox里,同时这边除去那一项。 在选到项时还好,就是如果没选中项直接双击的话,就会报页面错误说是“发生意外”我的js是这样的:
//雙擊鼠標添加email
function addDbclick()
{
var addOption=document.createElement("option");
var index;
if(document.all("emailaddr").length==0)
{
alert("無傚選項");
return(false);
}else
{
index=document.all("emailaddr").selectedIndex;
}
addOption.text=document.all("emailaddr").options(index).text;
addOption.value=document.all("emailaddr").options(index).value;
document.all("outselect").add(new Option(addOption.text,addOption.value));
if(!(index<0))
{
document.all("emailaddr").options.remove(index);
}
}请问怎么解决这个问题? 我对js不熟
//雙擊鼠標添加email
function addDbclick()
{
var addOption=document.createElement("option");
var index;
if(document.all("emailaddr").length==0)
{
alert("無傚選項");
return(false);
}else
{
index=document.all("emailaddr").selectedIndex;
}
addOption.text=document.all("emailaddr").options(index).text;
addOption.value=document.all("emailaddr").options(index).value;
document.all("outselect").add(new Option(addOption.text,addOption.value));
if(!(index<0))
{
document.all("emailaddr").options.remove(index);
}
}请问怎么解决这个问题? 我对js不熟
解决方案 »
- updatepanel 和 输出特俗字符串(乱码)的问题
- 求一个.net开发视频的解决方案,解决时间 100分送上 谢谢 本人比较急
- 非常郁闷+奇怪的问题,求教
- VS打包和卸载(怎样使卸载后还原到未安装软件的状态)
- javascript为何访问不到
- ★★★请问ASP.Net中,如何禁止webbrowser中的弹出对话框?
- 菜鸟问题:页面分离。望大家帮忙
- JS验证后,是否后台还需验证
- datagrid里的字段太多,横向放不下,datagrid能横向滚动吗?
- 不知这样的效果怎么实现????
- 求一个远程excel数据导入的例子
- 从lucene中检索到的结果如何与asp.net2003的DataGrid控件绑定
BTW, I'm not familiar with js either.
{
if(document.all("emailaddr").value==null||document.all("emailaddr").value=="")
{
return false;
}
var addOption=document.createElement("option");
var index;
if(document.all("emailaddr").length==0)
{
alert("無傚選項");
return(false);
}else
{
index=document.all("emailaddr").selectedIndex;
}
addOption.text=document.all("emailaddr").options(index).text;
addOption.value=document.all("emailaddr").options(index).value;
document.all("outselect").add(new Option(addOption.text,addOption.value));
if(!(index<0))
{
document.all("emailaddr").options.remove(index);
}
}