cfman Posted January 26, 2011 Share Posted January 26, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/225707-serious-php-help-needed/ Share on other sites More sharing options...
BlueSkyIS Posted January 26, 2011 Share Posted January 26, 2011 Googled: PHP Form Tutorial http://www.phpf1.com/tutorial/php-form.html Quote Link to comment https://forums.phpfreaks.com/topic/225707-serious-php-help-needed/#findComment-1165488 Share on other sites More sharing options...
cfman Posted January 26, 2011 Author Share Posted January 26, 2011 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.? Quote Link to comment https://forums.phpfreaks.com/topic/225707-serious-php-help-needed/#findComment-1165574 Share on other sites More sharing options...
kcmakwana Posted January 26, 2011 Share Posted January 26, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/225707-serious-php-help-needed/#findComment-1165575 Share on other sites More sharing options...
Cagecrawler Posted January 26, 2011 Share Posted January 26, 2011 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, Quote Link to comment https://forums.phpfreaks.com/topic/225707-serious-php-help-needed/#findComment-1165578 Share on other sites More sharing options...
cfman Posted January 27, 2011 Author Share Posted January 27, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/225707-serious-php-help-needed/#findComment-1165752 Share on other sites More sharing options...
jcbones Posted January 27, 2011 Share Posted January 27, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/225707-serious-php-help-needed/#findComment-1165757 Share on other sites More sharing options...
cfman Posted January 27, 2011 Author Share Posted January 27, 2011 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] Quote Link to comment https://forums.phpfreaks.com/topic/225707-serious-php-help-needed/#findComment-1165764 Share on other sites More sharing options...
l4nc3r Posted January 27, 2011 Share Posted January 27, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/225707-serious-php-help-needed/#findComment-1166272 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.