views:

35

answers:

2

I have 2 tables in my database call groups and players i am trying to select the group first and then the players show up in another listbox.

can anyone help me out please.

DB

Groups

 id            Name
 1             Red Group
 2             Blue Group
 3             Yellow Group

Players

 id           name         group_id
 1            User1           1
 2            User2           3
 3            User3           2
 4            User4           3
 5            User5           1
A: 

Its' simple.

load "Groups" listbox on page load from database query. Now call an ajax function on onChange event of Groups list box and send group_id to ajax function . make a div on ur page and show ajax response of selected group_id in div.

You can find sourse code on google search . use keywords country/state ajax dropdown.It will be done in same way. :)

seed_of_tree
+1  A: 

output group's records at server end, into a select, then ,as vasim said, use jquery's change (http://api.jquery.com/change/) to fire an ajax call which will populate palyers select by the group id.

$('#group').change(function()
{
   $.ajax(
   {
      url: 'url_to_server_script',
      data: 'group='+$('#group').val(),
      success: function(){/* populate here your players select*/}
   });
});

more info about jquery's ajax at http://api.jquery.com/jQuery.ajax/. depending on what your server script willr eturn you'll have to specify the ajax property datatype (json,xml,...)

Dalen