rafael rafael - 6 days ago 7
HTML Question

Letting PHP select an option in real time?

I'm building a CMS that have 2 database tables, subjects & pages ... I have two drop down lists..And i want to let the user to insert values in it ...

The first drop down list is to select which table to insert in. The second drop down list is to select the position of the inserted item in that selected table.

So I want the user to select the table first, then -using PHP- change the second drop down list to contain the available position in that table. Note that all the previous stuff is in the same web page without pressing any button or something.

So all I want, a method to make PHP check the selected option in the first drop down list, and change the options in the second according to the first drop down list, all that in the same page without pressing any button..

Is that possible in PHP ?

Answer

The short answer to your question is no. PHP is server side, i.e. it can't be changed by user interactions without refreshing the page as it has finished executing before the HTML reaches the browser.

To do this you will need to use javascript and ajax.

Comments