Filling in a form from a select dropdown.

Sorry if the title is a little confusing but I’ll try to explain it clearly here. Also, I’m using ColdBox for this project and I’ll be posting it to the ColdBox list so sorry in advance if you get it twice.

So the idea here is that I have a select box that will have more than one value.

Think of it as a selection of States for the US.

When the user selects a state, a query should be run that will then fill in the rest of the form.

The remainder of the form of the does have other select drop downs that should have a specific dropdown selected from the query that was returned.

The rest of the form has most text boxes that can be filled by the values that are returned from the query mentioned above.

I’m asking what is the best way of going about this? I’m also open to using jquery or just regular JavaScript to get the job done.

Thanks

The most straight forward way would be to create a proxy or regular CB event that renders JSON and hit it with jQuery Ajax. Pass the state or whatever in the URL send back JSON defining what needs to happen on the form. Just remember to secure any Ajax calls that modify data behind a login and re-validate any form data on the server side.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Hmmm… ok I’m a bit of a jQuery newb but more than willing to learn. Do you have any examples to point me in the right direction?

Thanks!

Not right off-- I’ve always used the CFAjaxProxy tag for Ajax stuff in conjunction with a ColdBox proxy.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Ok,

Thanks I’ll start there.

Chances of seeing this thread responded to again: high! :slight_smile:

You might check out ContentBox’s admin module—there are a bunch of jquery calls to ColdBox handlers in there

Thanks Joel,

I had not thought of that.

Sure thing. Now that I’m back to my computer, here’s an example:

https://github.com/Ortus-Solutions/ContentBox/blob/master/modules/contentbox-admin/views/pages/editorHelper.cfm

The quickSave() method posts via AJAX to the save() method in https://github.com/Ortus-Solutions/ContentBox/blob/master/modules/contentbox-admin/handlers/pages.cfc

Notice the event.isAjax() bits that help determine how to handle the incoming request and whether or not to change the rendering method.

Thanks for the example. I’m going to put ContentBox on my test box so I can watch it happen.