Ravi_Ramsagar Posted April 23, 2013 Share Posted April 23, 2013 I am a newbee in php, jquery and ajax. I have a code in jquery to add and remove the textboxes dynamically on button click. I want to post the values of dynamically created textbox values to next page and display those values on action page as well as insert them into db. Any help is much appreciated. Thanks in advance. Please click on the link to see how the textboxes are dynamically created. http://jsfiddle.net/NSePb/1/ I have uploaded the two pages. I want to post the data from quotations.phpquotations.php to quot_rec.php and display the posted values on quot_rec.phpquot_rec.php Link to comment https://forums.phpfreaks.com/topic/277193-how-to-post-the-dynamically-created-text-box-values-to-next-page-in-php-and-insert-those-values-into-db/ Share on other sites More sharing options...
jugesh Posted April 23, 2013 Share Posted April 23, 2013 populate the text fields name as array like <input type='textbox' id='Location1' name="Location[]"> now while saving the data follow like this: if ($_POST['Location']) { //get last inserted userid foreach ($_POST['Location'] as $key=>$value) { /// Do your coding.... } } Link to comment https://forums.phpfreaks.com/topic/277193-how-to-post-the-dynamically-created-text-box-values-to-next-page-in-php-and-insert-those-values-into-db/#findComment-1426049 Share on other sites More sharing options...
Ravi_Ramsagar Posted April 23, 2013 Author Share Posted April 23, 2013 Thanks jugesh for the response. I hope you seen the jsfiddle link and the pages I have uploaded. In the code the textboxnames are generated dynamically, I mean each time the user clicks the 'Add products' button the counter value gets incremented and the id and the name gets updated with that value for example when the user clicks the 'Add Products' button the textbox names are generated automatically as name="product" + counter, name="qty" + counter, name = "rates" + counter. So I want to gather all the dynamically generated textbox values to pass to quot_rec.php and display those values. I am facing difficulty in storing the dynamically generated textbox values to php variabples. I am working on this for nearly two days. Link to comment https://forums.phpfreaks.com/topic/277193-how-to-post-the-dynamically-created-text-box-values-to-next-page-in-php-and-insert-those-values-into-db/#findComment-1426065 Share on other sites More sharing options...
jugesh Posted April 23, 2013 Share Posted April 23, 2013 Change your input fields name as an array: newTextBoxDiv.after().html('<label>Product #'+ counter + ' : </label>' + '<input type="text" size="22" name="product[] " id="product' + counter + '" value="" > \n\ <label>Quantity #'+ counter + ' : </label>' + '<input type="text" size="1" name="qty[] " id="qty' + counter + '" value="" > \n\ <label>Rate #'+ counter + ' : </label>' + '<input type="text" size="2" name="rates[] " id="rates' + counter + '" value="" > \n\ <label>Total #'+ counter + ' : </label>' + '<input type="text" size="3" name="total[] " id="total' + counter + '" value="" > '); Now post the values as i did in example it will surely work Link to comment https://forums.phpfreaks.com/topic/277193-how-to-post-the-dynamically-created-text-box-values-to-next-page-in-php-and-insert-those-values-into-db/#findComment-1426081 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.