日期:2014-05-17 浏览次数:20424 次
<body>
<input type="button" value="input取值" onclick="getInputsText();" />
<select id="curSelect" onchange="selectChanged();" >
<option></option>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
</select></body>
function selectChanged() {
//父容器
var inputParent = document.getElementsByTagName("body")[0];
var select = document.getElementById("curSelect");
var selectValue = select.options[select.selectedIndex].value;
if (selectValue !== "") {
for (var i = 0; i < selectValue; i++) {
var input = document.createElement("input");
inputParent.appendChild(input);
}
}
}
//input 取值
function getInputsText() {
//父容器
var inputParent = document.getElementsByTagName("body")[0];