我正在尝试设置一个部件号配置工具,该工具根据几组单选按钮输出变量。我已经设法制作了一套显示器,但我无法弄清楚如何复制输出。理想情况下,对于默认检查的值,我希望警报显示“部件号为:(ledcolor)(shellcolor)”非常感谢任何帮助!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta content="stuff, to, help, search, engines, not" name="keywords">
<meta content="What this page is about." name="description">
<meta content="An Interesting Title Goes Here" name="title">
<title>An Interesting Title Goes Here</title>
<style>
</style>
</head>
<body>
<DL id="led">
<DT>LED Light Color:
<DD><INPUT TYPE="RADIO" NAME="ledcolor" id="ledcolor1" VALUE="R" checked>
Red
<DD><INPUT TYPE="RADIO" NAME="ledcolor" id="ledcolor2" VALUE="A">
Amber
<DD><INPUT TYPE="RADIO" NAME="ledcolor" id="ledcolor3" VALUE="RA">
Red/Amber Combination
<DD><INPUT TYPE="RADIO" NAME="ledcolor" id="ledcolor4" VALUE="B">
Blue
<DD><INPUT TYPE="RADIO" NAME="ledcolor" id="ledcolor5" VALUE="RB">
Red/Blue Combination
<DD><INPUT TYPE="RADIO" NAME="ledcolor" id="ledcolor6" VALUE="G">
Green
<DD><INPUT TYPE="RADIO" NAME="ledcolor" id="ledcolor7" VALUE="W">
White
<DD><INPUT TYPE="RADIO" NAME="ledcolor" id="ledcolor8" VALUE="I">
Infrared
</DL>
<DL>
<DT>Shell Color:
<DD><INPUT TYPE="RADIO" NAME="shellcolor" id="shellcolor1" VALUE="Y" checked>
Yellow
<DD><INPUT TYPE="RADIO" NAME="shellcolor" id="shellcolor2" VALUE="O">
Orange
<DD><INPUT TYPE="RADIO" NAME="shellcolor" id="shellcolor3" VALUE="BL">
Blue
<DD><INPUT TYPE="RADIO" NAME="shellcolor" id="shellcolor4" VALUE="BK">
Black
<DD><INPUT TYPE="RADIO" NAME="shellcolor" id="shellcolor5" VALUE="OD">
Olive Drab Green
<DD><INPUT TYPE="RADIO" NAME="shellcolor" id="shellcolor6" VALUE="T">
Tan
</DL>
<button onclick=display()>Show Part Number</button>
<script>
function display() {
var m = getRadioValue("ledcolor").value;
var s = getRadioValue("shellcolor").value;
alert("The part number is: " +m +"-"+ s);}
function getRadioValue(theRadioGroup)
{
var elements = document.getElementsByName(theRadioGroup);
for (var i = 0, l = elements.length; i < l; i++)
{
if (elements[i].checked)
{
alert("The part number is: " +elements[i].value);
}
}
}
</script>
</body>
</html>