1

I have a select box which contains all the teams in the DB in the table 'Team'. Each team plays for one or more divisions which are in the Division table. A team has many divisions and a division has many teams.

I am new to Ajax and need to retrieve all the divisions a team plays for when that team is selected in the dropdown field. Which code must i implement on the back and front end to achieve this? How can I pass the selected team with Ajax for it to return me some divisions? I understand I need PHP code to handle the request, but how do I pass the selected team so PHP knows what it needs to return?

Thanks. If you need some code let me know (but i haven't got any so far to handle this).

4
  • What did you do so far? Jul 15, 2015 at 11:39
  • Nothing so far, I have the select box, but nothing happens when I select a team. I haven't attempted an Ajax call or PHP function as I don't know how to pass the selected team with Ajax to PHP. Jul 15, 2015 at 11:44
  • Well, it's basically javascript on the client, on select event call some URL to get data from a controller, insert it somehow. Reminds me of the functionality of the tagfield,github.com/silverstripe-labs/silverstripe-tagfield , maybe it helps you to analyse that code.
    – wmk
    Jul 15, 2015 at 13:33
  • 2
    @JackO'Connor - Have you gone through Lesson 17 Ajax Behaviour and ViewableData? This should give help a lot
    – 3dgoo
    Jul 15, 2015 at 22:48

0

Your Answer

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

Browse other questions tagged or ask your own question.