Talk about JavaScript. Gets the value of the server control

Source: Internet
Author: User

Search from the Internet a lot of information, toss a half-day, finally fix, write down for everyone to reference

This was found on the Internet.

<script language= "JavaScript" >


function GetValue () {

var B = document.all.rbtid.length

var a = document.getElementById ("Rbtid"). Rows.length;

alert (b); result is 5

alert (a); result is 4

for (Var i=0;i<b-1;i++) This is OK

for (var i = 0; i < A; i++) {

var ss = "Rbtid_" + i;

var AA = document.getElementById (ss). Value;

if (eval (' Document.all.rbtid_ ' +i). Checked==true)//This can also be done by the Eval () function to turn the data character string into JS run

var bb = document.getElementById (ss);

if (document.getElementById (ss). Checked)//note checked can not be written checked, otherwise unsuccessful

{

alert (AA);

Break

}


}

}

</script>

RadioButtonList put it in the form and run.

But in the Ajax control Tabcontainer, the method fails.

So look at the source of the Web page, found the problem, modify it to be

function GetValue () {

var B = document.all.rbtid.length

var a = document.getElementById ("Rbtid"). Rows.length;

alert (b); result is 5

alert (a); result is 4

for (Var i=0;i<b-1;i++) This is OK

for (var i = 0; i < A; i++) {

var ss =document.getelementbyid ("<%=rbtid. Clientid%> "). Id+" _ "+i;

if (eval (' Document.all.rbtid_ ' +i). Checked==true)//This can also be done by the Eval () function to turn the data character string into JS run

var bb = document.getElementById (ss);

if (document.getElementById (ss). Checked)

var AA = document.getElementById (ss). Value;

if (eval (' Document.all.rbtid_ ' +i). Checked==true)//This can also be done by the Eval () function to turn the data character string into JS run

var bb = document.getElementById (ss);

if (document.getElementById (ss). Checked)//note checked can not be written checked, otherwise unsuccessful

{

alert (AA);

Break

}


}

}



Talk about JavaScript. Gets the value of the server control

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.