demand
<select>
Drop down to select the content,<input>
The corresponding content is displayed in the input box.
implementation
<! DOCTYPEhtml>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="Width = device - width, initial - scale = 1.0">
<title>Document</title>
</head>
<body>
<table border="1px" style="width:530px; height: 320px; border-style: groove">
<tr style="height: 40px;">
<td style="width: 170px;">
<center>Please fill in the account application form below</center>
</td>
<td bgcolor="#99ccff"></td>
</tr>
<tr style="height: 40px;">
<td style="width: 170px; text-align:right">Class level:</td>
<td>
<select id="banji" onchange="setXuehao(this.value)" style="width: 160px; height: 35px;">
<option selected>Please select a class</option>
<option value="xinguan171">Fuse 171</option>
<option value="xinguan172">Fuse 172</option>
</select>
</td>
</tr>
<tr style="height: 40px;">
<td style="width: 170px; text-align:right">Study no. :</td>
<td>
<input type="text" id="xuehao">
<span style="color: red">*</span>
<span>Note: Only student id can be entered.</span>
</td>
</tr>
</table>
<script>
function setXuehao() {
// var selectidValue = document.getElementById('banji').options[document.getElementById('banji').selectedIndex].value;
var selectidValue = document.getElementById('banji').options[document.getElementById('banji').selectedIndex].value;
var inputValue = document.getElementById('xuehao').value;
// if(document.getElementById('banji').selectedIndex ! = 0)
// document.getElementById('xuehao').value="2017102341"+document.getElementById('banji').selectedIndex;
if (selectidValue == "xinguan171")
document.getElementById('xuehao').value = "2017102341";
else if (selectidValue == "xinguan172")
document.getElementById('xuehao').value = "2017102342";
else
document.getElementById('xuehao').value = "";
}
</script>
</body>
</html>
Copy the code