var sel = document.formname.selectname;
for(var i=0;i<sel.options.length;i++){
if(sel.options[i].value=="xxxx"){
sel.options[i].selected = true;
break;
}
}
for(var i=0;i<sel.options.length;i++){
if(sel.options[i].value=="xxxx"){
sel.options[i].selected = true;
break;
}
}
问一下,可不可以设置DropDownList的属性值呢?
1、DropDownCheckList的控件名:CDept
2、窗体名为Form1。
var sel = document.Form1.Drp_CDept;
alert(sel);
for(var i=0;i<sel.options.length;i++)
{
if(sel.options[i].value=="1004")
{
sel.options[i].selected = true;
}
else if((ndave>1002)&&(ndave<1006)&&(sel.options[i].value =="1005"))
{
sel.options[i].selected =true;
}
else
{
sel.options[i].selected=false;
}
}
alert(sel)提示为NULL呀
if(typeof(objList)=="object")
{
var nCount=objList.children.item.length;
for(var i=0; i<nCount-1;i++)
{
var item=objList.children.item(0);
var chItem =item.children.item(i);
//
if ( typeof(chItem)=="object")
{
alert(chItem);
/*
if(item.children.item(i).value =="1004")
{
item.children.item(i).selected =true;
}
else if((ndave>1002)&&(ndave<1006)&&(objList.children.item(i).value =="1005"))
{
objList.children.item(i).selected =true;
}
else
{
objList.children.item(i).selected=false;
}*/
}
}
}
请问带注释部分怎么表达
for (int i = 0; i < ddclRank.Items.Count; i++)
{
ddclRank.Items[i].Selected = true;
}