Functions that use javascript to obtain radio values are not commonly used when combined with background languages such as asp and php, but are required in a pure js environment.
<Input name = "R1" type = "radio" value = "1"/> 1 <input name = "R1" type = "radio" value = "2"/> 2 <input name = "R1" type = "radio" value = "3"/> 3 <input name = "R1" type = "radio" value = "4"/> 4 <input type = "BUTTON" value = "OK" onclick = "SelR1 (); "> <script language =" JavaScript "> <! -- Function SelR1 () {var Obj = document. getElementsByName ("R1"); for (I = 0; I <Obj. length; I ++) {if (Obj [I]. checked) {break }}; if (I = Obj. length) {alert ("no choice! ");} Else {alert (Obj [I]. value) ;}}// --> SCRIPT
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
The second method is the same as the first method.
The Code is as follows:
// Preview the Function
Var colorid = "";
Function ShowTemp (){
Var eless = document. getElementsByName ("colorStyle ");
For (var I = 0; I // Alert (eless [I]. checked + eless [I]. name + eless [I]. id );
If (eless [I]. checked)
{
Colorid = eless [I]. value;
Break;
}
}
Alert (colorid + "--");
}