function initSelect() { var selectIndex=document.getElementById("ddlPharmacy").selectedIndex; for(var i=0;i<document.getElementById("ddlPharmacy").options.length;i++) { document.getElementById("ddlPharmacyData").options.add(new Option(document.getElementById("ddlPharmacy").options[i].text,document.getElementById("ddlPharmacy").options[i].value)); } document.getElementById("ddlPharmacy").options.length=0; var group0 = document.createElement('OPTGROUP'); group0.id = "ddlPharmacy_grp_"; group0.label = ""; document.getElementById("ddlPharmacy").appendChild(group0); for(var i=0;i<document.getElementById("ddlPharmacyData").options.length;i++) { var group = document.createElement('OPTGROUP'); group.id = "ddlPharmacy_grp_" + i; group.label = document.getElementById("ddlPharmacyAddress").options[i].text; group.style.color="#777777"; group.style.fontStyle="normal"; group.style.fontWeight="normal"; var textOpt=document.getElementById("ddlPharmacyData").options[i].text; var valueOpt=document.getElementById("ddlPharmacyData").options[i].value; var optionObj=new Option(textOpt,valueOpt); optionObj.style.color="black"; document.getElementById("ddlPharmacy").options.add(optionObj); document.getElementById("ddlPharmacy").appendChild(group); } document.getElementById("ddlPharmacy").selectedIndex=selectIndex; }