This article mainly introduces how to get the display value of the drop-down box in javascript and how to judge the single-choice button. It provides an example of how javascript performs operations on the html drop-down box and single-choice button, for more information about how to obtain the display value of the drop-down box and determine the single-choice button in JS, see the following example. Share it with you for your reference. The details are as follows:
1. I have done many projects and need to get the value displayed by the select component. The following are my frequently used methods:
The Html source code is as follows:
BeijingShanghaiJiangsuHebei
The JS functions are as follows:
Function setTxt () {var _ selObj = document. getElementByIdx_xx ('province '); // retrieve the element var _ selVal = _ selObj [_ selObj. selectedIndex]. text; // retrieves the selected document from the drop-down list. getElementByIdx_xx ('provincename '). value = _ selVal ;}
2. I have also done a lot to determine whether the radio button is selected. The following are my frequently used methods:
The source code of the HTML page is as follows:
2009-05-202009-05-212009-05-222009-05-23
JS function code:
Function judge () {var status = false; var _ radObj = document. getElementsByName ('time'); for (var I = 0; I <_ radObj. length; I ++) {if (_ radObj [I]. checked) {status = true ;}} if (! Status) {alert ('unselected time! ');} Return status ;}
I hope this article will help you design javascript programs.