<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>无标题文档</title>
</head>
<body>
<input type="radio" name="sex" value="男" checked>男 <input type="radio" name="sex" value="女">女</body>
</html>
PHP中文网2017-04-10 15:21:03
try this...
function s() {
var person = document.forms['person'];
if(person.sex.value=="男") {
alert("先生您好");
} else {
alert("女士您好");
}
}
update
function s() {
var person = document.forms['person'];
if(person.elements['sex'][0].checked) {
alert("先生您好");
} else {
alert("女士您好");
}
}