Como se muestra a continuación:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="ajaxselect.OnmouseTitle.WebForm1" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ><HTML> <HEAD> <title>WebForm1</title> <meta content = "Microsoft Visual Studio .net 7.1" name = "Generator"> <meta content = "c#" name = "code_language"> <meta content = "javascript" name = "vs_defaultClientscript"> <meta content = "http://schemas.microsoft.com/intelliseSense/ie5" name = "vschem lenguaje = "javascript"> función getValue () {var b = document.all.rbtid.length var a = document.getElementById ("rbtid"). cells.length; // alerta (b); El resultado es 5 // alerta (a); El resultado es 4 // para (var i = 0; i <b-1; i ++) Esto funciona para (var i = 0; i <a; i ++) {var ss = "rbtid _"+i; var aa = document.getElementById (SS) .Value; //if(Eval('Document.all.rbtid_'+i).ecked==true) // Esto funciona para evaluar () la función para convertir la cadena de datos en js y ejecutar var bb = document.getElementById (ss); if (document.getElementById (ss) .ecked) // Tenga en cuenta que no se puede escribir como se verifica como se verifica, de lo contrario no tendrá éxito {alerta (aa); romper; }}}O use el segundo método:
// Get RadioButtonList var vrbtid = document.getElementById ("rbtid"); // Obtener todas las radio var vrbtidList = vrbtid.getElementsBytagName ("entrada"); for (var i = 0; i <vrbtidList.length; i ++) {if (vrbtidList [i] .ecked) {var text = vrbtid.cells [i] .innertext; value var = vrbtidList [i] .Value; alerta ("El valor de texto del elemento seleccionado es"+text+", y el valor es"+valor); }}En este método, RadioButtonList se considera una tabla en el lado del cliente, y todas sus radios infantiles se obtienen a través del método GetElementsByTagName ("Entrada"), luego enojen cada radio y luego obtenga el valor de texto de la radio a través de las celdas.
</script> </head> <body ms_positioning = "gridLayout"> <form1 id = "form1" método = "post" runat = "servidor"> <font face = "宋体"> <asp: radioButtonList id = "rbtid" style = "Z-Index: 101; izquierda: 8px; posición: absoluta; top: 8px" runat = "servidor =" servidor "width =" "width" width "width" width "width" width "width" width "width" width "width" width "width" width "width" width "width" width "width" width "width" width "width" " Altura = "176px" name = "rbtid"> <asp: listEm value = "0"> 0 </asp: listItem> <asp: listem value = "1" seleccionado> 1 </asp: listitem> <asp: listitem value = "2"> 2 </asp: listItem> <Sp: listem value = "3"> 3 </asp: listemem> </ASP: RadioButtonList> <input style = "Z-Index: 102; izquierda: 184px; Position: Absolute; Top: 256px" onClick = "getValue ()" type = "button" valor = "botón"> </font> </form> </body> </html>
Los dos métodos anteriores (recomendados) para obtener el valor seleccionado por RadioButtonList en JS son todo el contenido que comparto con usted. Espero que pueda darle una referencia y espero que pueda apoyar más a Wulin.com.