Must not recommend jQuery, I must not recommend jQuery, I must not recommend
jQuery, I must not recommend jQuery, I must not recommend jQuery.
Use jQuery! :OD
<script type="text/javascript" src="PATH TO JQUERY"></script>
<script type="text/javascript">
$(function() {
$("button").click(function() {
var firstValue = $("#field1").val();
$.post("the CFM page that returns the value",
{value1: firstValue}, function(data) {
$("#field2").val(data);
});
return false;
});
});
</script>
<form action="#CGI.SCRIPT_NAME#" method="post">
<input type="text" id="field1" />
<input type="text" id="field2" />
<button>Do something</button>
</form>
If you want quick and dirty this is about as simple as it gets. The CFM page
you post to on clicking the button needs to return the value you want for
the second field. That's the basic concept, then you can move into returning
JSON and XML instead of raw strings.
I loves me some jQuery :OD
Oh, and that script is untested.
Adrian
> -----Original Message-----
> From: Andrew Peterson [mailto:[email protected]]
> Sent: 04 March 2009 17:07
> To: cf-talk
> Subject: Populate form field based on query run after another form
> field is set
>
>
> Hi,
>
> You guys prolly do this every day. Say I've got a form with two fields.
> When a user enters the value in field a, I'd like to query the db and
> populate field b with the result of the query whose where clause is
> based on the value set in field A. I could do this after the form is
> submitted, but that is sooo web 1.0. A link to a tutorial or other
> suggestions to get me pointed in the right direction is greatly
> appreciated. TIA
>
> Andy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:320101
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4