Я пытаюсь получить forloop с входными элементами для запуска между формой и создать форму динамически с помощью JavaScriptзаселения динамической формы с JavaScript
1: в случае одной, форма в сценарии становится закрыта до элементы ввода заполняются.
2: в сценарии два, когда я помещаю переменную цикла for между формой, ошибка, которая приходит, не определена.
ПОМОГИТЕ
СЦЕНАРИЙ ONE
<form>
No of Feilds <input type="text" id= "numberoffeilds">
<input type="button" value = "Create Feilds" onclick= "addfeilds1();">
</form>
<div id= "div4" style= "color:gray"></div>
<script>
function addfeilds1()
{
var totalfeilds = document.getElementById("numberoffeilds").value;
var i;
document.getElementById("div4").innerHTML += '<form action= "issue.html" method = "POST">';
for(i=0;i<totalfeilds;i++)
{
document.getElementById("div4").innerHTML += '<input type = "text">';
}
document.getElementById("div4").innerHTML += '<input type = "submit" value="submit" name="submit">';
}
</script>
СЦЕНАРИЙ TWO
<form>
No of Feilds <input type="text" id= "numberoffeilds">
<input type="button" value = "Create Feilds" onclick= "addfeilds2();">
</form>
<div id= "div4" style= "color:gray"></div>
<script>
function addfeilds2()
{
var totalfeilds = document.getElementById("numberoffeilds").value;
var i;
function forloop()
{
for(i=1 ;i<totalfeilds;i++)
{
document.getElementById("div4").innerHTML += '<input type = "text">';
}
}
var loopvar = forloop();
document.getElementById("div4").innerHTML += '<form action= "issue.html" method = "POST">'+
'<input type = "text">'+
loopvar + // it shows the loop as undefined
'<input type = "text">'+
'<input type = "text">'+
'<input type = "submit" value="submit" name="submit">';
}
</script>
новичок в использовании StackOverflow, Ват я хотел подразумевать это differenciate как сценарии 2 дифф .. может я редактировать. ? – Sebastian
спасибо adeno, я исправился .. – Sebastian
спасибо mouser ... :) – Sebastian