<!DOCTYPE html>
<html>
<head>
<title>sex</title>
</head>
<script type="text/javascript">
window.onload=function()
{
var oBtn=document.getElementById('btn1');
oBtn.onclick=function()
{
var oName=document.getElementById('name').value;
var oSex=document.getElementById('sex').value;
switch(oSex)
{
case 'man':
alert(oName+'先生,你好');
break;
case 'woman':
alert(oName+'女士,你好');
break;
default:
alert(oName+'你好');
}
}
}
</script>
<body>
<input type="text" id="name">
<input type="text" id="sex">
<input type="button" value="确定" id="btn1">
</body>
</html>
网友评论