javascript獲取Select當(dāng)前值

字號(hào):


    javascript獲取Select當(dāng)前值,具體代碼如下:
    function GetObjID(ObjName)
    {
    for (var ObjID=0; ObjID < window.frm2.elements.length; ObjID++)
    if ( window.frm2.elements[ObjID].name == ObjName )
    {
    return(ObjID);
    break;
    }
    return(-1);
    }
    function select1Get(ObjName)
    {
    select1id = GetObjID(ObjName);
    for (i=window.frm2.elements[select1id].length-1; i>=0; i--)
    {
    if (window.frm2.elements[select1id].options[i].selected)
    {
    select1Value = window.frm2.elements[select1id].options[i].text;
    }
    }
    }