#2 select option input 1 submit form and save the result of 2 select option in 1 row

21 messages · Page 1 of 1 (latest)

blissful parcel
molten arch
#

@blissful parcel It's not possible to do that with just html. You'll need the inputs to have separate names and then combine them in your controller.

blissful parcel
#

my select option depends on my foreach loops

#

because im basing on the services that the user inquired in our website. so if the user have 2 inquired services, then my select option will become 2 as well.

blissful parcel
molten arch
#

<select name="paymentStatus1"></select>
<select name="paymentStatus2"></select>

#

But why not just have those two fields separated in the database as well?

#

If they are separate inputs, they should probably be separate fields in the database. You can then query on either one of them.

blissful parcel
#

but my select is based on foreach loops of how many services the user inquired in our website.

#

ex the user inquired the service 1, service2, and service 4 which is 3 services.

then my select will become 3 as well.

molten arch
#

Ah, okay. I'd make it a JSON column then. Then you can still easily query against it.

#

You could use a multiple select instead.
<select multiple name='services[]' />

#

Otherwise, you are going to have to use some javascript

blissful parcel
#

pls look at the image sir. the user inquired 2 services and then i used foreach for that to generate the select input on the right side. what i want is to get the updated selected status of the inquired services and save it on my database using only 1 row.
expected output: availed,availed (based on the selected input on the picture)

#

the problem also is because my select input is based on foreach, the names of select input are the same

#

so if i try to get the value of all of my select, im only getting 1 value.

molten arch
#

So name the inputs differently.

blissful parcel
#

i got and save the value of my select input on the database now

#

my problem is it becomes an array

#

the value with ["4","1","2"]