Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Set Value of Form Objects Without Submitting?

Reply
Thread Tools

Set Value of Form Objects Without Submitting?

 
 
HumanJHawkins
Guest
Posts: n/a
 
      02-17-2004
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!


 
Reply With Quote
 
 
 
 
Cletus Lee
Guest
Posts: n/a
 
      02-17-2004
In article <EFrYb.7469$(E-Mail Removed). net>, http://www.velocityreviews.com/forums/(E-Mail Removed)
says...
> 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';

--

Cletus D. Lee
http://www.clee.org
- Bellaire, TX USA -
 
Reply With Quote
 
 
 
 
Larry C. Lyons
Guest
Posts: n/a
 
      02-18-2004
HumanJHawkins wrote:

> 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/ex...000288&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.

 
Reply With Quote
 
Paul Dempsey
Guest
Posts: n/a
 
      02-18-2004
"HumanJHawkins" <(E-Mail Removed)> wrote in message news:<EFrYb.7469$(E-Mail Removed) link.net>...
>
> 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
 
Reply With Quote
 
Ci-Ci Mills
Guest
Posts: n/a
 
      02-18-2004
I usually go with WDDX for a problem like this. Only one trip to the
DB and it is fast.

Here is an example:
http://www.procept.net/coldfusion/tu...lainClient.cfm

"Larry C. Lyons" <(E-Mail Removed)> wrote in message news:<HXzYb.39155$(E-Mail Removed)>. ..
> HumanJHawkins wrote:
>
> > 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/ex...000288&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

 
Reply With Quote
 
Cam Penner
Guest
Posts: n/a
 
      02-19-2004
In article <f7ec4036.0402181313.196385a6
@posting.google.com>, (E-Mail Removed) says...
> I usually go with WDDX for a problem like this. Only one trip to the
> DB and it is fast.
>
> Here is an example:
> http://www.procept.net/coldfusion/tu...lainClient.cfm


Presuming, of course, that there is a small number of small
results sets.

WDDX is very expensive on bandwidth. (compared to regular
lists) If you have a large number of result sets, or a
large amount of data, WDDX becomes very unwieldily.

--
Cam
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retrieve form field value if form is EncType=multipart/form-dataForm? Li Zhang ASP .Net 4 02-27-2009 01:23 AM
class objects, method objects, function objects 7stud Python 11 03-20-2007 06:05 PM
design patterns: value objects vs. data transfer objects laredotornado@zipmail.com Java 1 08-29-2006 12:14 AM
form objects into class objects =?Utf-8?B?c3RldmVuIHNjYWlmZQ==?= ASP .Net 1 07-06-2006 08:33 AM
Loop Form - extract display 'value' as well as form value? ASP General 2 02-20-2006 09:36 PM



Advertisments