0
The Problem: On one page I have two select, one selecting the team and the other the team members, the first (team) I fill the option
with php (per database query), so it will list all teams I have registered in the database. I want you to change the team on this select
, for him to carry on select
all members of this team (also recorded in the database).
I thought I’d do with Jquery
and Ajax
, in the change of select.equipe
he perform a request on a php page, which searches for members related to the id of the selected team. But I’m having trouble catching the return of php, because there will be more than one member.
I tried to mount in php a string
html with options and then give a append
of that string in select.membros
, but with no results.
I also tried with .html
in place of .append
. I searched several places and only found how to put option
one by one, and does not solve my case as I have to put several at the same time, and the results of the query are mounted in options with values corresponding to the member id and content
with the name of the member.
How do I add multiple options in select.membros
and delete the same in .change
of select.equipe
? Or if you have a better method of doing this (changing the select.members options according to the select.team change) as I do?
Sorry for the bad formatting, it’s urgent and I’m by phone.
Why not return a JSON to PHP? Then just iterate the list/array and add each element of it as a team member.
– DH.