简体   繁体   中英

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 ?

You can use PHP in the background, but as selecting an option happens on the client side you'll have to use a combination of JavaScript/Ajax.

Have a look at YUI Autocomplete or other Ajax autocomplete frameworks.

The short answer to your question is no. PHP is server side, ie 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM