I need to create some dynamic functionality and am unsure of where to begin. I have a page where you can create a Contact, we have an auto suggest field for “Company Name”, this populates with all the companies you’ve created from within the application.
You then have the option to fill out the address for the Contact your creating, we want a checkbox that reads, “Same as company”, so when checked, it’ll populate all the fields with that companies address information.
I know how to do the final piece in jQuery, however, how do I dynamically pull the value from the auto suggest field and look it up in the database to pull the address data?
Do I need to setup a variable that is equal to the value in this field? (company_name).
Then do
SELECT * from companies where company_name = company_name
Do I already have access to the data I need or do I need to do more work?
It depends on how you are doing the auto suggest. If you use the jQuery UI Autocomplete control (http://jqueryui.com/autocomplete/), it supports returning complex data from the server. So your server would return the company name AND address. You can then use code to handle the select (ie, when the user picks a company) and copy that address info into JavaScript variables. When the user clicks the checkbox, you would then just copy it.