Call a PHP function on SELECT element change and get result as JSON format

Call a PHP function on SELECT element change and get result as JSON format

Hi, I'm working in a new application built on top of CodeIgniter (PHP). I have several html SELECT element, each element has a associated value in a DB table. What I need to do, and don't know how (know it's using .ajax but not so sure about the syntax or how to get the things as I want) is to make a AJAX call when users change the SELECT element and populate a INPUT element with the associated value. See the example below:

 Table in DB:
 id: 1
 name: option1
 value: value1

 id: 2
 name: option2
 value: value2

When users change from option1 to option2 I should write value2 in a INPUT and viceversa when change back to option1 then the same INPUT should be updated to option1, how? Any help?

Thanks in advance