0

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.

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         |
+-----+-----------+------------+
1
  • What sort of mark-up are you working with? Commented Oct 23, 2010 at 10:51

1 Answer 1

1

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,...)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.