function citychosed()
{
var province=document.getElementById("province");
var city=document.getElementById("city");
var hidepc=document.getElementById("hidepc");
if(province.options[province.selectedIndex].text=="选择省份")
{
alert("请选择省份");
hidepc.value="0";
return;
}
else if(city.options[city.selectedIndex].text=="选择城市")
{
alert("请选择城市");
hidepc.value="0";
return;
}
else
{
hidepc.value=province.options[province.selectedIndex].text+"--"+city.options[city.selectedIndex].text;
}
}
//添加LIstBox项
function AddItem()
{
var lb=document.getElementById("ListBox");
var hidepc=document.getElementById("hidepc");
var count=lb.options.length;
var falg=1;
if(lb.options.length<3)
{
if(hidepc.value!="0")
{
for(var i=0;i<count;i++)
{
if(hidepc.value==lb.options[i].text)
{
falg=0;
alert("该项已存在");
return;
}
else
{
falg=1;
}
}
if(falg==1)
{
lb.options[count]=new Option(hidepc.value,count ,true,true);
}
//hidepc.value为Text内容 count为Vlaue内容
}
}
else
{
alert("您已经选择了三项");
}
}
//删除LIstBox项
function DeleteItem()
{
var lb=document.getElementById("ListBox");
var flag=0;
for(var i=0;i<lb.options.length;i++)
{
if(lb.options[i].selected==false)
{
flag+=1;
}
}
if(flag==lb.options.length)
{
alert("请选择要移除的项");
}
else
{
lb.options[lb.selectedIndex].parentNode.removeChild(lb.options[lb.selectedIndex]);
}
}
//清除所有LIstBox项
function DeleteAll()
{
var lb=document.getElementById("ListBox");
for(var i=lb.options.length;i>0;i--)
{
lb.options[i-1].parentNode.removeChild(lb.options[i-1]);
}
}
//将一个ListBox的项全部复制给另外一个ListBox
function change()
{
var sb=window.document.getElementById("SourceListBox");
var length=sb.options.length;
for(var i=0;i<length;i++)
{
var texts=sb.options[i].text;
var values=sb.options[i].value;
var db=window.document.getElementById("DestinationListBox");
db.options[i]=new Option(texts,values,true,true);
}
}