[Javascript] gping thrui the select options and checking iof there is any selected

dev at qroute.net dev at qroute.net
Tue Jun 8 15:05:35 CDT 2004


Following code checks if there is any check/radio box is checked;

        CurRadioChecked=false
        for(var x = 0; x <
window.document.frmSurvey.anObjectNameHere.length; x++)
        {
         if (window.document.frmSurveyanObjectNameHere[x].checked)
         {
          CurRadioChecked= true;
          break;
         }
        }

What if the object is not a radio/checkbox, but a select box ? How do you
find out if there is any item is selected ?
Assumption :

First option in the select  box would be "SELECT ONE FROM LIST" and it would
by default is the selected one and its value would be "" ( empty string )




More information about the Javascript mailing list