Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/411.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将动态文本框值传递到另一个php页面_Php_Javascript - Fatal编程技术网

如何将动态文本框值传递到另一个php页面

如何将动态文本框值传递到另一个php页面,php,javascript,Php,Javascript,我通过javascript制作了一个动态文本框,现在我想将所有动态生成的文本框的数据发布到php脚本中,然后插入到一个表中。我怎样才能做到这一点 > var intTextBox=0; > > //FUNCTION TO ADD TEXT BOX ELEMENT > function addElement() { > intTextBox = intTextBox+1; > > var contentID = document.getElemen

我通过javascript制作了一个动态文本框,现在我想将所有动态生成的文本框的数据发布到php脚本中,然后插入到一个表中。我怎样才能做到这一点

> var intTextBox=0;
> 
> //FUNCTION TO ADD TEXT BOX ELEMENT 
> function addElement() { 
> intTextBox = intTextBox+1;
> 
> var contentID = document.getElementById('content'); 
> var newTBDiv =document.createElement('div');
> newTBDiv.setAttribute('id','strText'+intTextBox); 
> newTBDiv.innerHTML="Author  : <input type='text' id='citingfield' name='"intTextBox"'/>";
> contentID.appendChild(newTBDiv);
> }
> 
> //FUNCTION TO REMOVE TEXT BOX ELEMENT 
> function removeElement() {
> if(intTextBox != 0) 
> {
> var contentID = document.getElementById('content');
> contentID.removeChild(document.getElementById('strText'+intTextBox));
> intTextBox = intTextBox-1; } }
> 
> <body>
> 
> <form action="add_save.php" method="post"  > 
> 
> <div id="content"></div> <p><a href="javascript:addElement();"
> >Add</a> <a href="javascript:removeElement();" >Remove</a></p>
> 
> <input name="submit" type="submit" id=" " value="Submit">
> </from>

您可以使用$_POST['intTextBox']获取此文本框的值,并使用它插入到表中

只需使用POST方法,您将在另一页中获取所有填充的值

--- index.php---    
    <form method="POST" action="destination.php">
    your code here. Dynamically created code will append to here
    </form>

 -----destination.php---

    print_r($_POST)
您可以使用$\u POST数组。 使用带括号的相同名称。 您可以查看此帖子:

在javascript中为任何要动态添加的文本框执行此操作

      var box=document.createElement("input");
      box.setAttribute("type","text");
      box.setAttribute("name","box1");
      box.setAttribute("value","someNewValue");
      content.appendChild(box);
然后在add_save.php中提交后执行此操作

 $boxValue=$_REQUEST['box1'];

 <tr><?=$boxValue ?></tr>

您必须在表单标签中提及操作属性,请更正它