سؤال

I have a dynamic html form that creates with javascript new inputs for some products and each product has more colors.

<input type="text name="products[]">
<input type="text name="colors[]">

How do i create this html code so that when i have them in the post i could relate them with a for.

هل كانت مفيدة؟

المحلول

do it like this:

<input type="text name="products[product_index][name]">
<input type="text name="products[product_index][colors][]">

or :

<input type="text name="products[product_index]">
<input type="text name="[colors][product_index][]">
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top