Jump to content

Submitting data from dynamic form


siric

Recommended Posts

Hi,

 

I have a dynamic form which uses javascript to add rows on the fly.  The name of the element on my test page is txtRow1, txtRow2, etc; the number is added when I add a new row.

 

I am trying to figure out how I will extract the data once the form had been POSTED.

 

I have tried

 

$tags = $_POST['txtRow'];


   foreach ($tags as $t)
   {
       echo "$t<br />";
   }

 

 

but that shows nothing.

 

 

I would be grateful for any assistance.

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/245994-submitting-data-from-dynamic-form/
Share on other sites

This is where the field name is defined in the javascript

 

// Last updated 2006-02-21

function addRowToTable()

{

  var tbl = document.getElementById('tblSample');

  var lastRow = tbl.rows.length;

  // if there's no header row in the table, then iteration = lastRow + 1

  var iteration = lastRow;

  var row = tbl.insertRow(lastRow);

 

  // left cell

  var cellLeft = row.insertCell(0);

  var textNode = document.createTextNode(iteration);

  cellLeft.appendChild(textNode);

 

  // right cell

  var cellRight = row.insertCell(1);

  var el = document.createElement('input');

  el.type = 'text';

  el.name = 'txtRow' + iteration;

  el.id = 'txtRow' + iteration;

  el.size = 40;

 

 

 

How would I then define it as an array?

 

Thanks

 

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.