javascript - How can I concat the content of dynamic textboxes to a single variable? -


here file (test.php) try run on localhost. javascript works , creates text boxes. php-part not work , makes problem.

    <html>     <head>     <title>test</title>       <script>       function newcheckbox() {     var alabel = document.form1.getelementsbytagname('label');     var last = alabel[alabel.length-1];     var label = document.createelement('label');     label.appendchild(box(alabel.length));      label.appendchild(document.createtextnode('     '+document.getelemenbyid('text').value));            last.parentnode.insertbefore(label, last);      document.getelementbyid('text').value = '';      }  function box(num) { var elm = null;  try {      elm=document.createelement('<input type="checkbox" class="chk">');     }   catch(e) {      elm = document.createelement('input');     elm.setattribute('type', 'checkbox');     elm.classname='chk';    }     return elm;     }      function delboxes(){      var texts = document.form1.getelementsbytagname('label');     var chbox = document.form1.getelementsbyclassname('chk');     for(var = 0; i<texts.length-1; i++){     if(chbox[i].checked){        chbox[i].parentnode.removechild(chbox[i]);        texts[i].parentnode.removechild(texts[i]);         }      }   }   </script>     <?php     $text_0= $_post['text[0]'];    echo $text_0;   $textboxes = array();      for($i = 0;$i<count($_post['text[]']); $i++)     {        $textboxes = $_post['text'][$i];      }          $data=$textboxes      ?>   </head>   <body>      <form action="test.php" name="form1" method="post">      <div>       <label>checkbox text:<input type="text" name="text[]"></label><br>     <input type="button" onclick="newcheckbox();"value="add">     <input type="button" value="delete" onclick = "delboxes();" />      </div>     </form>      </body>    </html> 

when run code have following problem undefined index: text[0] undefined index: text[]

i appreciates help.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -