Populating a dropdown box based on text field data


I am trying to populate a dropdown list based on the text provided in the text field. I wish to populate Address Line 1 based on the post code provided. Data has to come from a function with various different values. A dropdown and two text fields will get populated with data returned.

How do we achieve this? please help.


Hello Yasir. Is your function on the client side or the server side? How do you call it?

I have a form with text field post code. Once a text is entered in the field, a button on front of the field will be clicked to populate following fields:

  1. a drop down field with all the door numbers

  2. a text field for town will be filled

  3. a text field for city will be filled

all this data has to come from a php functions will will return 3 variables?

variable 1 will be an array of door numbers

variable 2 will be a normal variable containing town name

variable 3 will be a normail variable containing city name

the function which will be returning these variables will first receive post code as explained above and based on that post code the required information will get populated. An XML web service will be returning that data and I intend to get that XML data converted in to above variables.

Ok, so I guess when you click that button, there’s some controller action using the post code field value, fired through ajax to retrieve the variables.

It’s easy to parse XML by PHP, so I suggest you’d parse your returned values in PHP, and return JSON values that you’ll display into your input fields on success of the ajax call.