我想使用javascript代码访问用户创建的输入块

问题描述 投票:1回答:1
<script type="text/javascript">
    function add(element){
 var form = window.document.dynamicForm;
 // We clone the add button
 var add = element.cloneNode(true);
 // Create a new HTML tag of type "input"'

   my_form=document.createElement('FORM');
   my_form.name='myForm';


//var field = document.createElement("input");

 // The value filled in the form will be stored in an array
// field.name = "champs[]";
// field.placeholder = "champs[input]";
// field.type = "text";
//MAIN DOCUMENTATION

my_tb=document.createElement('INPUT');
my_tb.type='TEXT';
my_tb.name='myInput';
my_tb.placeholder='Values of my Input';
my_form.appendChild(my_tb);

my_tb1=document.createElement('INPUT');
my_tb1.type='text';
my_tb1.name='myInput1';
my_tb1.placeholder='Values of my hidden1';
my_form.appendChild(my_tb1);

my_tb2=document.createElement('INPUT');
my_tb2.type='text';
my_tb2.name='myInput2';
my_tb2.placeholder='Values of my hidden1';
my_form.appendChild(my_tb2); 

document.body.appendChild(my_form);

 var rem = document.createElement("input");
 rem.value = "Remove a field";
 rem.type = "button";
 // Add the onclick event
 rem.onclick = function onclick(event)
  {del(this);};

 // We create a new element of type "p" and we insert the field inside.
 var bloc = document.createElement("p");
 bloc.appendChild(field);
 //form.insertBefore(add, element);
 //form.insertBefore(rem, element);
 form.insertBefore(bloc, element);}

先生在此先感谢.sir在这里我想访问用户在每个输入块中给出的输入。如果用户增加了输入块的数量,我可以在新块中获取输入文本并将其发送到我的php文件中存储该文件数据到数据库。请帮助我在用户点击添加列时访问新的和创建的输入块

javascript
1个回答
0
投票
document.forms["form_name"].getElementsByTagName("input");

请参阅get all the elements of a particular form

© www.soinside.com 2019 - 2024. All rights reserved.