In this case you are handling each of the results differently so you could
do it by putting anonymous functions directly in the post callbacks like
this:
$(document).ready(function(){
$("#Principal").blur(function(){
$.post("callpage_Validate_Mortgage_Inputs.cfm",
{principal:$("#Principal").val()}, function (data)
{$("#Result_Principal").empty().append(data) } ) });
$("#Interest").blur(function(){
$.post("callpage_Validate_Mortgage_Inputs.cfm",{interest:$("#Interest").val()},
function (data) {$("#Result_Interest").empty().append(data) }) });
$("#Years").blur(function(){
$.post("callpage_Validate_Mortgage_Inputs.cfm",{years:$("#Years").val()},
function (data) {$("#Result_Years").empty().append(data) }) });
});
OR you could pass the target div to an outside function like this:
$(document).ready(function(){
$("#Principal").blur(function(){
$.post("callpage_Validate_Mortgage_Inputs.cfm",
{principal:$("#Principal").val()}, function (data) {
handleCallback("Principal",data); }) });
$("#Interest").blur(function(){
$.post("callpage_Validate_Mortgage_Inputs.cfm",{interest:$("#Interest").val()},
function (data) { handleCallback("Interest",data); }) });
$("#Years").blur(function(){
$.post("callpage_Validate_Mortgage_Inputs.cfm",{years:$("#Years").val()},
function (data) { handleCallback("Years",data); }) });
});
function handleCallback(target,data) {
$("#Result_" + target).empty().append(data);
}
In general you should avoid creating outside functions inside the
document.ready function for cleanliness if nothing else.
Rick Faircloth wrote:
>
> Hi, Daemach...
>
> I've been working with the various suggestions I've gotten and
> have made some progress. I had to spend most of yesterday
> trying to figure out why my computer wouldn't boot. Finally
> isolated a software problem with a virtual CD emulator. Deleted
> that and all is well.
>
> Now with my code...
>
> The outcome I'm looking for now is to have the error message appear
> above each form field. Here's an online demo of what's happening:
>
> http://bodaford.whitestonemedia.com/html/trial_field_validation.cfm
>
> I get duplicate error messages and in the wrong spots...
> I don't know how to combine the elements to make
> them function properly. Any ideas?
>
> Thanks!
>
> Rick
>
> Here's the code...
>
> <script type="text/javascript">
>
> $(document).ready(function(){
>
> $("#Principal").blur(function(){
> $.post("callpage_Validate_Mortgage_Inputs.cfm",
> {principal:$("#Principal").val()}, handleCallback) });
>
> $("#Interest").blur(function(){
>
> $.post("callpage_Validate_Mortgage_Inputs.cfm",{interest:$("#Interest").val(
> )}, handleCallback) });
>
> $("#Years").blur(function(){
>
> $.post("callpage_Validate_Mortgage_Inputs.cfm",{years:$("#Years").val()},
> handleCallback) });
>
> function handleCallback(data) {
>
> $("#Result_Principal").empty().appendTo("#Result_Principal").append(data);
>
> $("#Result_Interest").empty().appendTo("#Result_Interest").append(data);
>
> $("#Result_Years").empty().appentTo("#Result_Years").append(data);
>
> }
>
> });
>
>
>
> </script>
>
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> Behalf Of Daemach
> Sent: Thursday, March 15, 2007 12:26 AM
> To: [email protected]
> Subject: Re: [jQuery] Ok... one last effort to make this work... help!
>
>
> Did you get this working Rick?
>
>
>
>
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
>
--
View this message in context:
http://www.nabble.com/Ok...-one-last-effort-to-make-this-work...-help%21-tf3399722.html#a9495623
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/