1

I am trying to create a set of dropdown boxes that are interconnected using PHP and JavaScript.

My objective is to read an input value from a dropdown box, and use it to determine the values of other dropdown boxes.

An example of this is a dropdown list for States where the user takes the following actions:

  1. Choose a State
  2. Choose the province within that State
  3. Choose the city within that province

I wish to do something like this, but reading value from the Database and use the afore mentioned techonologies.

1
  • 3
    can you show what you have tried I mean code that you tried to solve this problem?? Commented Apr 22, 2016 at 16:24

2 Answers 2

1

Database queries are executed by PHP. PHP is executed on the server-side.

HTML is rendered on the client-side, which is where user interactions take place.

So to get information from the database based on user interaction, you need to make an HTTP request to get information back from the server.

To do this, you would use AJAX. Read up on that for the solution to your problem.

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

Comments

0

Without specifying any libraries that you are using one can only guess. However, after a quick search, I recommend the following plugin:

Github also has a very interesting project regarding this:

These solutions will help you avoid the need to use a DB. However, if you really need to do it, then you have to use AJAX and make at least a request to the server.

Overall if you use a library like jQuery or a Framework like Angular things can be easier, but you can still manage with what you have.

Hope it helps!

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.