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
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

 

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.