Fill form elements based on dropdown

Fill form elements based on dropdown

Hi,

 

I'm pretty new to PHP, and I had to realize that even PHP is not enough for my desires...
So as browsed many forums, I suppose I need some Javascript to reach my goal. I have a form, which contains a dropdown and let's say one text input field:

  1. <form name="anything" method="post">
  2. <select name="dropdown">
  3.       <option value=1>First</option>
  4.       <option value=2>Second</option>
  5. </select>
  6. <input name="city" type="text">
  7. </form>

My goal is to run a query each time the user changes the value of the dropdown, and fill in the result to the text input. I know that I have to put the query into a separate .php file, but I don't know how to activate it and hand over the result. Where and what should I insert?
Thank you in advance!

Kazi

P.s.: I'm I right if I need to do something similar if I want to enable or disable a text input based on the value of a certain checkbox?