<html>
<head>
<title>第一个javascript</title>
<script language = "javascript">
<!--
function changeTextValue() {
document.forms[0].oneText.value = document.forms[0].oneText.value.toUpperCase();
}
function selectCheckBox() {
if(document.forms[0].oneCheck.checked) {
alert("恭喜你,你选中了");
}
}
function selectRadio() {
var radio = document.forms[0].oneRadio;
var i;
for(i = 0; i < radio.length; i++) {
if(radio[i].checked) {
break;
}
}
alert("你选择了" + radio[i].value );
}
function oneSelected() {
var one = document.forms[0].oneSelect;
var selectValue = one.options[one.selectedIndex].text;
alert(selectValue);
}
-->
</script>
</head>
<body>
<form action="" method="post">
<input type="text" name="oneText" value ="sheng" onChange="changeTextValue()"></br>
<input type="checkbox" name="oneCheck" value ="sheng" onClick="selectCheckBox()">sheng</br>
<input type="checkbox" name="twoCheck" value ="sheng" checked>sheng1
</br>
<input type="radio" name="oneRadio" value ="men" onClick="selectRadio()" checked>男
<input type="radio" name="oneRadio" value="women" onclick="selectRadio()">女
</br>
<select name="oneSelect" onChange="oneSelected()">
<option value="men" selected>men1
<option value="women">women1
</select>
</form>
</body>
</html>
js的基本东西
最新推荐文章于 2024-07-03 14:04:55 发布