Set Value of Form Objects Without Submitting?


H

HumanJHawkins

Hi,

We have a project where a form needs to have several fields... Drop down
lists and text boxes mostly. The problem is that one of the drop down menus
needs to be populated based on the value in another drop down menu.

So, we want to use "onChange" for the first field to run a query to fill the
second field. But all of the examples we have found require us to submit the
form before the data is accessible. If we submit the form, then any of the
other fields that might have been filled out are lost.

Is there any way to say something like:

onChange = Get the value of the changed item and run a query. Then fill this
other drop down menu with the returned results of that query.

Thanks!
 
Ad

Advertisements

C

Cletus Lee

Hi,

We have a project where a form needs to have several fields... Drop down
lists and text boxes mostly. The problem is that one of the drop down menus
needs to be populated based on the value in another drop down menu.

So, we want to use "onChange" for the first field to run a query to fill the
second field. But all of the examples we have found require us to submit the
form before the data is accessible. If we submit the form, then any of the
other fields that might have been filled out are lost.

Is there any way to say something like:

onChange = Get the value of the changed item and run a query. Then fill this
other drop down menu with the returned results of that query.

This is normally managed on the client side using javascript.

Using if{} or switch{} logic to set a value like
document.<formname>.<formfieldname>.value = 'what ever it needs to be';
 
L

Larry C. Lyons

HumanJHawkins said:
Hi,

We have a project where a form needs to have several fields... Drop down
lists and text boxes mostly. The problem is that one of the drop down menus
needs to be populated based on the value in another drop down menu.

So, we want to use "onChange" for the first field to run a query to fill the
second field. But all of the examples we have found require us to submit the
form before the data is accessible. If we submit the form, then any of the
other fields that might have been filled out are lost.

Is there any way to say something like:

onChange = Get the value of the changed item and run a query. Then fill this
other drop down menu with the returned results of that query.

Thanks!
look on the macromedia developer's exchange by a tag called
CF_TwoSelectsRelated,
http://www.macromedia.com/cfusion/e...snid=sn106&itemnumber=1&extid=1000288&catid=0

From the site:
Puts two SELECT form elements onto the current page, which contain
choices from any query. The two SELECTs are related -- when the user
chooses an item from the first SELECT, the items from the second SELECT
are "filled" with corresponding items for the user to choose from.

hth,
larry

--

Larry C. Lyons

========================================================
Life is Complex. It has both real and imaginary parts.
========================================================
Chaos, Panic and Disorder. My work here is done.
 
P

Paul Dempsey

HumanJHawkins said:
We have a project where a form needs to have several fields... Drop down
lists and text boxes mostly. The problem is that one of the drop down menus
needs to be populated based on the value in another drop down menu.

So, we want to use "onChange" for the first field to run a query to fill the
second field. But all of the examples we have found require us to submit the
form before the data is accessible. If we submit the form, then any of the
other fields that might have been filled out are lost.

Is there any way to say something like:

onChange = Get the value of the changed item and run a query. Then fill this
other drop down menu with the returned results of that query.

You can use JavaScript to set values in a second select element based
on a change in the first select element. You can't do this with a
query to the server without leaving the page you are on (that is,
submitting the form).

There are some options to do this. You can use ColdFusion on the form
to populate JavaScript arrays, so the onChange will work as you
specified. This could be a problem if the number of possible select
items is very large.

Another option is to do a multi-part form. Based on selections made in
part 1, certain options are made available in part 2. You can pass
form data along from one part to another with hidden fields, or you
can update the database as you go along.

Paul Dempsey
Dickinson College
 
Ad

Advertisements

Ad

Advertisements


Top