<SELECT>标签用multiple属性来控制多选或单选,默认为单选,即没有multiple属性,所以设置单选则使用JS的removeAttribute函数移除multiple属性即可,代码如下所示:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html>
<head>
<title>Select 单选</title>
</head>
<body>
<select name="s2" size="6" style="width:100px" id="s2" multiple="multiple">
<option>选项1</option>
<option>选项2</option>
<option>选项3</option>
<option>选项4</option>
<option>选项5</option>
</select>
<script type="text/javascript">
var s2=document.getElementById("s2")
s2.removeAttribute("multiple")
</script>
</body>
</html>
效果如下:
把var
text1=document.getElementById("turface-pro-league-num-pallets").value
提到函数外面去,作为全局变量.text2也如此.这样在函数内部,text1的值就不会发生变化了.