HTML code
Copy codeThe Code is as follows:
<Asp: RadioButtonList ID = "rbtnCompany" runat = "server"
RepeatColumns = "4" RepeatDirection = "horizontal">
<Asp: ListItem Value = "1" Text = "A"> </SPAN> asp: ListItem>
<Asp: ListItem Value = "2" Text = "B"> </SPAN> asp: ListItem>
<Asp: ListItem Value = "3" Text = "C"> </SPAN> asp: ListItem>
<Asp: ListItem Value = "4" Text = "D"> </SPAN> asp: ListItem>
<Asp: RadioButtonList>
<Input id = "Button1" type = "button" value = "button" onclick = "return RadioButtonList1Changed ()"
JS Code:
Copy codeThe Code is as follows:
Function RadioButtonList1Changed ()
{
Var rbtn = document. getElementByIdx_x ("rbtnCompany ");
// Get all radio
Var list = rbtn. getElementsByTagName_r ("input ");
For (var I = 0; I <list. length; I ++ ){
If (vRbtidList [I]. checked ){
Var text = rbtn. cells [I]. innerText;
Var value = list [I]. value;
Alert ("the text value of the selected item is" + text + ", and the value is" + value );
}
}
}
You can specify to obtain a value. The following statements are written in combination. Obtain the value of the first item whose index is 0.
Copy codeThe Code is as follows:
Alert (document. getElementByIdx_x ("rbtnCompany"). getElementsByTagName_r ("input") [0]. value); // The result is 1.