Jump to content

Archived

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

cfman

Serious PHP Help Needed

Recommended Posts

I have a form with dynamic text boxes that have dynamic names (i.e., TextBox1, TextBox2, etc.).  How do I get those variables passed into php?  I have tried and tried...even googled it, with no solid luck.  Any help, immediately, would be so much appreciated.

Share this post


Link to post
Share on other sites

Really did not solve anything....I have a form that has field names like:  Id_1, Id_2, etc.  There could be just one field (i.e., Id_1) or there could be 20 fields.  I need to be able to capture the variables in those fields.  Do I loop through the array, etc.?

Share this post


Link to post
Share on other sites

I have a form with dynamic text boxes that have dynamic names (i.e., TextBox1, TextBox2, etc.).  How do I get those variables passed into php?  I have tried and tried...even googled it, with no solid luck.  Any help, immediately, would be so much appreciated.

it is possible with the help of ajax xml or jquery. send me sample code I will tell you how to get result

Share this post


Link to post
Share on other sites

You can set the field name to id[] which will put all the id values into an array within $_POST.  Then it doesn't matter how many you have, you can just read them from the array,

Share this post


Link to post
Share on other sites

Did that and am able to get the results.  Now, how to actually put the results together.  For example, i have fields:  A1,B1,C1 and A2,B2,C2.  I need to output these variables into an email.  I got the email part figured out, no problem.  Just getting the form variables so they match up in the output:  A1 A2, B1 B2, C1 C2.

Share this post


Link to post
Share on other sites

Gonna need to see your code. We would be wasting our time, and yours, trying to guess how your form builds itself.  We love to help others, but it is very difficult to do so without relevant code.

 

foreach($_POST as $key => $value) {
if(is_array($value)) {
   foreach($value as $key2 => $value2) {
     echo $key2 . ' ' . $value2 . '<br />';
   }
}
}

 

This should print the variables to your page, it would take some more checks to line them up like you desire to do.

Share this post


Link to post
Share on other sites

I have attached the javascript file that builds the table and the hidden fields.  Also, it can be seen here (still under development, so please pardon):  http://www.usameddent.com/Test4.php?section=A.  Choose a quantity and add it to the cart.  Then click on the view cart link at the top left.  I come from a coldfusion background and am slowly wrapping myself around php as it is a nice language and I certainly appreciate the help.

 

[attachment deleted by admin]

Share this post


Link to post
Share on other sites

The way I handle dynamic forms is I create an array with them, so:

 

<input type="hidden" name="id[]" />

<input type="hidden" name="id[]" />

 

Which, on the next page will translate into

 

$_POST['id'][0];

$_POST['id'][1];

 

and so on.

Share this post


Link to post
Share on other sites

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