Jump to content

Perform query onChange


vchris

Recommended Posts

I am working on a complicated form. Now there is a select and depending on the choice of the select I have to return different records from the db. Is there a way to create a query that is only executed onChange event without page reload?<cfscript> maybe? I never worked with this tag before.

Link to comment
Share on other sites

it sounds like you are looking for a solution that uses either Flash Remoting or AJAX.I'm not completely following your request, but if one drop box is controlling the contents of another drop box, these are the only four options I know of:a.) use flash forms and flash remoting (no post back)b.) use html forms and AJAX (no post back)c.) use html or flash forms and create a post backd.) run all the queries hen the page loads and use javascript to populate the correct drop box for each selection (too much processing for large drop box selections)Is this pertenant to the application you are trying to build?

Link to comment
Share on other sites

Yes. That's basically it. If they choose option 1 in select 1 then select 2 will have choices relative to select 1 option 1. Should have only around 3-4 options in the second select.Is AJAX like javascript?

Link to comment
Share on other sites

Yes. That's basically it. If they choose option 1 in select 1 then select 2 will have choices relative to select 1 option 1. Should have only around 3-4 options in the second select.Is AJAX like javascript?
http://www.w3schools.com/ajax/ajax_database.aspWhen you select from the dropdown the record from the database changes (without the page loading), i guess you make a second dropdown with this new information if you wish.AJAX is partially java script: Asynchronous JavaScript And XML :)But hey i ain't had time to learn AJAX yet :blink: or Coldfusion :) So i'm outta here! :)
Link to comment
Share on other sites

Here's what I was looking for!http://www.indiankey.com/cfajax/examples/list.htmNow just need to understand it and make it work.EDIT:Even better http://www.fusionauthority.com/Techniques/...ldFusion-Part-IAnyone know what they mean by:

The code to achieve this in CFAJAX would look something like this (omitting the links to the include files that come with CFAJAX, as they depend on the developer's configuration):
I figured out that I need a library for ajax to work. I know Yahoo has a ajax library. Anyone know how to include and what file exactly to include? Do I have to download some files or can I just link to a site?
Link to comment
Share on other sites

what you bolded in your quote is basically telling you that all the files can be used as is. however, the <cfinclude> files that they provide might have to be modified (just the structure of the file path) so that you do not get a "template not found" ColdFusion error.If you get a clean page of AJAX and ColdFusion, I'd be interested in seeing/studying it. I know AJAX is only compatible with IE and FF, but it is something I'd like to consider toying with on a few intranet applications.(thanks in advance)

Link to comment
Share on other sites

it's only compatible with IE and FF!!! oh really? I didn't know that. Tell me what options do I have when I want to change the options in a select depending on the selected option in another select? I don't want any page reload.

Link to comment
Share on other sites

How would I do your D option in your second post?I know I can get all the records for that drop down but how can I only choose the ones needed with javascript?

Link to comment
Share on other sites

  • 1 month later...
How would I do your D option in your second post?I know I can get all the records for that drop down but how can I only choose the ones needed with javascript?
Sorry for not getting back to this, if it is still any help, here is the reply.For option D, where you run all your queries then use javascript . . . Lets say you have 7 queries that each list the respective countries on the various continents. In the first drop box, you would simply list all seven continents. Using javascript and the onchange function, you can determine which continent a user selected. Now, when the page loaded to begin with lets say you build a on row table with two columns. The left column is the drop box for the continents and the right column is the dynamic drop box that displays the respective country list for the selected continent. When the page loads, pre-build all your form optin groups - so you have 7 form option groups. Now, wrap each of them in a <div> that has a unique ID defined. Each <div> is then placed in that right column and each <div> is defined as such <div style="display:none;">. Use my show/hide function available in the javascript snippet forum and you can effectively show/hide each group of countries based on the continent you select.Let me know if this makes sense.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...