-3
이 프로그램에서는 첫 번째 입력 (텍스트 필드)이 길이를 나타내며 입력을 넣은 후 버튼을 클릭 한 후에 텍스트 필드의 수와 동일한 수의 텍스트 필드를 creaed합니다. 입력 길이. 내 문제는 내가 캡처 한 첫 번째 입력이지만 어떻게 동적으로 텍스트 필드를 만들지 모르겠다. 여기 내 코드입니다 :Idynamic에서 JavaScript로 입력 태그를 만드는 방법은 무엇입니까?
<html>
<body>
<input name="mioTesto" id="mioTesto" type="text" value="" size="40" maxlength="200" />
<button onclick="catturaValore()">Inserisci Valore</button>
<script>
function catturaValore() {
var valore = document.getElementById("mioTesto").value;
var maxIndice = parseInt(valore);
var container = document.getElementById("container");
for (var i = 0; i < maxIndice; i++) {
var input = document.createElement("input" + i)
input.name = "mioTesto"
input.id = i;
input.type = "text";
input.size = "40";
input.malength = "200";
input.className = "css-class-name"; // set
container.appendChild(input);
}
}
</script>
<button onclick="ordinaVettore()">Ordina</button>
</body>
</html>
태그에 번호를 추가하면 '+ i'가 제거됩니다. 유효하지 ? – adeneo
@adeneo 동일하게 작동하지 않습니다! – user4480370