I have three identical drop down lists that I’m populating using MySQL data.
If one of them changes index (onchange is fired), I want the other two to re-populate, so that they exclude the item that has been chosen with the other drop down list.
In ASP.NET, I would simply have called a function (passing through the chosen items’ value) in the code behind to re-populate the other two.
I’ve been poking around for a while now and I just can’t get it done with PHP. Does PHP allow function calling from this event? I’ve also tried using AJAX, but nothing.
You can’t (directly) call server side functions from the client side.
You can make an HTTP request to a URL that runs a server side script that calls the function.
ASP.NET has (I believe, I’ve never used it) some stuff that will set up a URL and generate some JavaScript that will call that URL for you.
There is nothing in the PHP core to do that.
A very rough, quick and dirty outline (that makes no attempt to be RESTful) of how you might go about doing something like that would be:
Then your JS would make an ajax request to
callFunction.php?call=functionA.