The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> processing javascript array with PHP
joyful
post Aug 28 2011, 01:39 PM
Post #1


Advanced Member
****

Group: Members
Posts: 239
Joined: 15-November 10
Member No.: 13,147



Hey!

I am dynamically creating form inputs with this script:
CODE

var counter = 1;
var limit = 40;
function addInput(divName){
     if (counter == limit)  {
          alert("You have reached the limit of steps: " + counter);
     }
     else {
          var newdiv = document.createElement('div');
          newdiv.innerHTML = "Entry " + (counter + 1) + " <br><input type='text' name='myInputs[]'>";
          document.getElementById(divName).appendChild(newdiv);
          counter++;
     }
}

(I found the above script here)

This script works great! The issue arises when I attempt to process the data with PHP:
CODE

$myInputs = $_POST["myInputs"];
foreach ($myInputs as $eachInput) {
     echo $eachInput . "<br>";
}

I seem to only be able to get the contents of the first input using the above script. What am I doing wrong? Should this work? I followed the tutorial at www.randomsnippets.com exactly; yet, it seems not to work!

Thanks in advance! blush.gif

--
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 24th April 2024 - 08:37 AM