I was working on Web six years ago. Three years ago, I was bored with web development. Recently, I picked up Web development again and forgot how to use radio.
Document. getelementbyid ("radioname"). value does not work, So Google knows that this is not the case.
The following is an example:
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> untitled document </title>
<Script language = "JavaScript">
Function getradioboxvalue (radioname)
{
VaR OBJ = Document. getelementsbyname (radioname );
For (I = 0; I <obj. length; I ++ ){
If (OBJ [I]. Checked ){
Return OBJ [I]. value;
}
}
Return "undefined ";
}
Function ABC (){
VaR A = getradioboxvalue ("radiobutton ");
Alert ();
}
</SCRIPT>
</Head>
<Body>
<Form ID = "form1" name = "form1" method = "Post" Action = "">
<Label>
<Input type = "radio" name = "radiobutton" value = "AA"/>
AA </label>
<Label>
<Input type = "radio" name = "radiobutton" value = "BBB" checked/>
Bbb </label>
<Label>
<Input type = "radio" name = "radiobutton" value = "CCC"/>
CCC </label>
<Input type = "Submit" name = "Submit" value = "Submit" onclick = "ABC ()"/>
</Form>
</Body>
</Html>