JS get the Drop-down box to display the value and judge the radio button method _javascript tips

Source: Internet
Author: User

The example of this article tells JS to get the Drop-down box display value and judge the radio button method. Share to everyone for your reference. Specifically as follows:

1. I have done many projects, need to get the value of the Select component display. Here are some of the methods I use frequently:

HTML source code is as follows:

 
 

The JS function is as follows:

function Settxt ()
{
 var _selobj=document.getelementbyidx_xx (' Province ');//Remove the element var of the Pull box
 _selval=_ selobj[_selobj.selectedindex].text;//Remove the selected value
 document.getelementbyidx_xx (' Provincename ') of the Drop-down box. Value=_selVal;


2. I have also done a lot to determine whether the radio radio button is selected, the following is my common method:

HTML page source code is as follows:


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 with your JavaScript programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.