У меня есть html-форма, в которую я хотел бы добавить поля ввода для использования javascript. Первоначально у меня были поля ввода под «телом», и следующие были в состоянии добавить поля:
// Create number input field
var phoneInput = document.createElement("INPUT");
phoneInput.id = "phone" + instance;
phoneInput.name = "phone" + instance;
phoneInput.type = "text";
// Insert that stuff
document.body.insertBefore(document.createElement("BR"), element);
document.body.insertBefore(phoneLabel, element);
document.body.insertBefore(phoneInput, element);
Затем я добавил элемент 'form' вокруг исходного ввода в html-файле.
<body>
<form action=searchform.php method=GET>
<LABEL for="phone1">Cell #: </LABEL>
<input id="phone1" type="text" name="phone1">
<input type="button" id="btnAdd" value="New text box" onclick="newTextBox(this);" />
</form>
</body>
Теперь кнопка не добавляет новые текстовые поля. Я неправильно структурировал это?
Спасибо!