var sel = document.forms[0].elements("Emp").value; alert(sel); var pos = sel.selectedIndex; //'Displaying "undefined alert(pos); var optText = sel.options[pos].text; //"Error in 'options' is null or not an object "
function ViewAllted() { if(document.forms[0].Emp.value!=''){ //var sel = document.getElementById("Emp"); var sel = document.forms[0].elements("Emp").value; alert(sel); var strValue = sel.options[sel.selectedIndex].value; alert('Sselected Value is: ' + strValue + ' and Index is: ' + sel.selectedIndex); var optText = sel.options[strValue ].text; document.forms[0].EmpName.value = optText; } document.forms[0].action="FORMEMP.aspx?M=V" document.forms[0].submit(); } else { alert("Select an Employee!") } } <input type="button" onclick="Javascript: ViewAlloted()" value="View Existing Allocation" />
var sel = document.getElementById("Emp"); var strValue = sel.options[sel.selectedIndex].value; alert('Selected Value is: ' + strValue +' and Index is: ' + sel.selectedIndex);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)