var url = "MagEmp?emp="+escape(emp.value); if (window.XMLHttpRequest) { req = new XMLHttpRequest(); }else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } if(req){ req.open("GET", url, true); req.onreadystatechange = callback; req.send(null); } }
function callback() { if(req.readyState == 4) { if(req.status == 200) { parseMessage(); }else{ alert("Not able to retrieve description"+req.statusText); } } }
function parseMessage() { var xmlDoc=req.responseXML.documentElement; var xSel=xmlDoc.getElementsByTagName('select'); var select_root=document.getElementById('magId'); select_root.options.length=0;
for(var i=0;i<xSel.length;i++) { var xValue=xSel[i].childNodes[0].firstChild.nodeValue; var xText=xSel[i].childNodes[1].firstChild.nodeValue; var option=new Option(xText,xValue); try{ select_root.add(option); }catch(e){ } } }