js selectの例
2321 ワード
<html>
<head>
<title>js select </title>
<script language="javascript" type="text/javascript">
function isSelected(ah) { //
if (ah.value != "" && ah.value != null) {
var ss = document.getElementsByTagName("select"),temp = [];
for (var i=0;i<ss.length;i++) {
if (ah.value == ss[i].value) {
temp.push(ss[i].value);
}
}
if (temp.length > 1) {
alert(" !!!");
ah.value = "";
}
}
}
function showCsmc() { // select
var cs = document.getElementById("cs");
if (cs.value !="" && cs.value != null) {
alert(" :" + cs.value + " :"
+ cs.options[cs.selectedIndex].innerHTML);
}
}
</script>
<body>
<select id="ah" onchange="isSelected(this);">
<option value="">-- _1--</option>
<option value="1"> 1</option>
<option value="2"> 2</option>
<option value="3"> 3</option>
</select>
<select id="ah" onchange="isSelected(this);">
<option value="">-- _2--</option>
<option value="1"> 1</option>
<option value="2"> 2</option>
<option value="3"> 3</option>
</select>
<select id="ah" onchange="isSelected(this);">
<option value="">-- _3--</option>
<option value="1"> 1</option>
<option value="2"> 2</option>
<option value="3"> 3</option>
</select>
<select id="cs" onchange="showCsmc();">
<option value="">-- --</option>
<option value="sh"> </option>
<option value="hz"> </option>
<option value="bj"> </option>
</select>
</body>
</html>