Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP loop through multi textboxes jquery

Featured Replies

Hi there,

 

I would like a bit of help cracking how to go about looping through multipul textboxes of which are generated via jquery.

 

Example structure.

 

 

<input type="text" class="textbox1" id="itemcode"/> <input type="text" class="textbox1" id="itemnme"/> <input type="text" class="textbox1" id="itemdesc"/>
<input type="text" class="textbox2" id="itemcode"/> <input type="text" class="textbox2" id="itemnme"/> <input type="text" class="textbox2" id="itemdesc"/>
<input type="button" id="addbox"/><input type="button" value="submit"/>
 

 

 

Jquery button can add new textboxes counting up.

 

I need PHP to loop through the submitted results so that all of textbox1 row go into the mysql table as 1 row, textbox2 as a second row, etc.

But, there will be seperate values that need to go into another table at the same time such as itmnme and itmcode but not itmdesc.

 

Any help much appreciated. Sorry if iv not explained this very well.

 

Thanks

Edited by Tex0gen

Hi there,

 

I would like a bit of help cracking how to go about looping through multipul textboxes of which are generated via jquery.

 

Example structure.

 

 

<input type="text" class="textbox1" id="itemcode"/> <input type="text" class="textbox1" id="itemnme"/> <input type="text" class="textbox1" id="itemdesc"/>
<input type="text" class="textbox2" id="itemcode"/> <input type="text" class="textbox2" id="itemnme"/> <input type="text" class="textbox2" id="itemdesc"/>
<input type="button" id="addbox"/><input type="button" value="submit"/>
 

 

 

Jquery button can add new textboxes counting up.

 

I need PHP to loop through the submitted results so that all of textbox1 row go into the mysql table as 1 row, textbox2 as a second row, etc.

But, there will be seperate values that need to go into another table at the same time such as itmnme and itmcode but not itmdesc.

 

Any help much appreciated. Sorry if iv not explained this very well.

 

Thanks

i think u are meaning you want something like this

 

<input type="text" class="textbox1" name="data[]" id="itemcode"/> <input type="text" class="textbox1" id="itemnme"/> <input type="text" class="textbox1"  id="itemdesc" name="data[]"
/>
<input type="text" class="textbox2" id="itemcode" name="data[]" /> <input type="text" class="textbox2" id="itemnme" name="data[]" /> <input type="text" class="textbox2" id="itemdesc" name="data[]" />
<input type="button" id="addbox"/><input type="button" value="submit"/>

Notice where it says name="data[]" this will put all submitted values in a array that u can access and loop through a single post request using $_POST['data'];

Edited by webdesigner93

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.