enrique_aeo
asked on
<asp:RadioButtonList get value in the code behind
hi guys, as I can get and value of what the user has selectionof? to process it in the code behind
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you want to get at client side, use :
function getSelectedValue(rbListName) {
var inputs = document.forms[0].getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++) {
if ( inputs[i].name.indexOf(rbListName)>=0 && inputs[i].type == "radio" && inputs[i].checked) return inputs[i].value;
}
}
example of using :
<table>
<tr class="TableItemAltFirst">
<td class="style4">Seguimiento o crítica fundada en los precedentes. Universalidad.</td>
<td>
<asp:RadioButtonList ID="rblSeguimientoCritica" runat="server" RepeatDirection="Horizontal" >
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr class="TableItemAltSecond">
<td class="style4">Innovación fundada en la interpretación creativa, posible y razonable del derecho, o del ordenamiento jurídico.</td>
<td>
<asp:RadioButtonList ID="rblInovacionFundada" runat="server" RepeatDirection="Horizontal" >
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
</table>
<script language="javascript" type="text/javascript">
function checkRadioIsSet() {
var inputs = document.forms[0].getElementsByTagName("input");
var allForEachGroupIsChecked = true;
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].type == "radio") {
var oneIsChecked = false;
var lastName = inputs[i].name;
while (lastName == inputs[i].name) {
if (inputs[i].checked) oneIsChecked = true;
i++;
}
i--;
allForEachGroupIsChecked = allForEachGroupIsChecked && oneIsChecked;
}
}
if (allForEachGroupIsChecked) {
return allForEachGroupIsChecked;
}
else {
alert("choose an answer for all questions!");
return allForEachGroupIsChecked;
}
}
function getSelectedValue(rbListName) {
var inputs = document.forms[0].getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++) {
if ( inputs[i].name.indexOf(rbListName)>=0 && inputs[i].type == "radio" && inputs[i].checked) return inputs[i].value;
}
}
</script>
<asp:Button ID="btnSave" runat="server" Text="Grabar Informacion" OnClientClick="return checkRadioIsSet();" />
<asp:Button ID="Button1" runat="server" Text="get selected value for Seguimiento Critica" OnClientClick="alert(getSelectedValue('rblSeguimientoCritica'));" />
<asp:Button ID="Button2" runat="server" Text="get selected value for Inovacion Fundada" OnClientClick="alert(getSelectedValue('rblInovacionFundada'));" />
ASKER
Please leakim971,
please, could you complete the example in the code behind?
please, could you complete the example in the code behind?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
rblSeguimientoCritica.Sele
and
rblInovacionFundada.Select