JS Select RadioButton Drop-down menu check box drop-down list radio button value

Source: Internet
Author: User

JS Select RadioButton Drop-down menu check box drop-down list radio button value

Select a value for RadioButton
function Chooseradiovalue (radioname,value)
{
var radio = Document.getelementsbyname (Radioname);
for (var i = 0;i < radio.length;i++)
{
if (Radio[i].value = = value)
Radio[i].checked = true;
}
}

Select the specified value for the Drop-down menu
function Chooseselectvalue (selectname,value)
{
var DDL = oo (selectname);
for (var i = 0;i < ddl.length;i++)
{
if (Ddl.options[i].value = = value)
Ddl.selectedindex = i;
}
}
The specified value selected
function Choosecheckboxvalue (checkboxname,value)
{
if (Value = = ") return;
var ary = Value.split (', ');
var cehckbox = Document.getelementsbyname (checkboxname);
for (var k = 0; k < ary.length;k++)
{
for (var i = 0;i < cehckbox.length;i++)
{
if (Cehckbox[i].value = = Ary[k])
Cehckbox[i].checked = true;
}
}
}

//Get Drop-down list text
function Getselecttext (selectid)
{
 
   try
   {
 & nbsp;  var sel = oo (selectid);
      return sel.options[sel.selectedindex].text;
  }catch (e) {return "";}
  
}
//Get Drop-down list value
function Getselectvalue (selectid)
{
   try
   {
    var sel = oo (selectid);
    return sel.options[sel.selectedindex].value;
   }
    catch (E)
    {
        return "";
   }
}
//Get check box value

Function Getcheckboxvalue (chkname)
{
   var chk = Document.getelementsbyname (chkname);
    var str = "";
   for (var i = 0;i < chk.length;i++)
     if (chk[i].checked)
  & nbsp;       str + + Chk[i].value + ",";
   if (str!= "") str = STR.SUBSTR (0,str.length-1);      
   return str;
}
//Get list box value
function Getlistvalue (listid)
{
   var sel = oo (listid);
   var St r = "";
   for (i=0;i<sel.length;i++)
     if (sel.options[i].selected)
 & nbsp;        str + + sel.options[i].value + "|";
   if (str!= "") str = STR.SUBSTR (0,str.length-1);      
   return str;
}

//Get radio button value
function Getradiovalue (radioname)
{
   var radio = Document.getelementsbyname ( Radioname);
      for (i=0;i<radio.length;i++)
        if (radio[i].checked)
          return radio[i].value;
  return ";       
}
//Get radio button object
function Getradioobj ( Radioname)
{
   var radio = document.getelementsbyname (radioname);
       for (i=0;i<radio.length;i++)
        if (radio[i].checked)
          return radio[i];
  Return "";       
}

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.