I'd use this as your submit handler
submitHandler:function(){
varParams={};
$("input:text").each(function(){
Params[$(this).attr("name")]=$(this).val();
})
$.post("Mortgage_Calculation.cfm",Params,function(data){
$("#Result").empty().append(data);
})
}
without the extra function.
shorter code, means less places for errors!
On 3/11/07, Aaron Heimlich <[EMAIL PROTECTED]> wrote:
> You should probably get rid of the onClick attribute (which you shouldn't be
> using anyway, but that's a different matter). You only want
> CalculateMortgage to be called if the form is valid, not whenever the
> "Calculate" button is clicked.
>
> On 3/11/07, Rick Faircloth <[EMAIL PROTECTED]> wrote:
> > I found out, too, that the problem below is in reference to this line in
> the
> > HTML:
> >
> > <INPUT ID="Calculate" Value=" Calculate " Type="Button"
> > onClick="CalculateMortgage();return false;">
> >
> > Please see the note below for a full description of the problem.
> >
> > Anyone got any ideas?
> >
> > Rick
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> > Behalf Of Rick Faircloth
> > Sent: Sunday, March 11, 2007 11:48 PM
> > To: 'jQuery Discussion.'
> > Subject: [jQuery] How do I fix this error?
> >
> > Hi, all...
> >
> > Using Jorn's Validation plug-in and trying
> > to use a submitHandler.
> >
> > Firebug is giving me this error:
> >
> > "CalculateMortgage is not defined"
> >
> > Can someone tell me what I need to do to
> > the Calculate Mortgage function to define it?
> >
> > Thanks for any help!
> >
> > Rick
> >
> > Here's the full jQuery code involved:
> >
> > <script type="text/javascript">
> >
> > $.validator.defaults.debug = true;
> > $().ready(function() {
> >
> > // validate Mortgage_Calculation_Form form fields on keyup
> > $("#MC_Form").validate({
> >
> > errorPlacement: function(error, element) {
> >
> > if(element.attr('id') ==
> "Principal") {
> > error.appendTo("#principal_error");
> > }
> >
> > else
> >
> > if(element.attr('id') == "Interest") {
> > error.appendTo("#interest_error");
> > }
> >
> > else
> >
> > if(element.attr('id') == "Years") {
> > error.appendTo("#years_error");
> > }
> >
> > }, //closes errorPlacement function
> >
> > focusInvalid: "false",
> >
> > event: "keyup",
> >
> > rules: {
> >
> > Principal: {required:
> true,
> > number:
> true},
> > Interest: {required:
> true,
> > number:
> true},
> > Years: {required: true,
> > number: true}
> > },
> >
> > messages: {
> >
> > Principal: {required:
> "Please enter the
> > Principal.",
> > number:
> "Please enter a
> > number. Format: 255000 (No $ or , )"},
> > Interest: {required:
> "Please enter the
> > Interest Rate.",
> > number:
> "Please enter a
> > number."},
> > Years: {required: "Please
> enter the Years.",
> > number:
> "Please enter a
> > number."}
> > },
> >
> >
> > submitHandler: function(){
> >
> > function
> CalculateMortgage(){
> >
> >
> var Params = {};
> >
> >
> // select all
> > inputsof type text
> >
> > $("input:text").each(function(){
> >
> > Params[$(this).attr("name")]= $(this).val();
> >
> }); // closes
> > input:text function
> >
> > // "post"
> the form. The
> > Param object mimics form fields
> >
> > $.post("Mortgage_Calculation.cfm", Params,
> function(data){
> > // this
> is the processing
> > function.
> >
> > // append
> what you get back
> > to the element with ID = Result after clearing its contents
> >
> > $("#Result").empty().append(data);
> >
> > } //
> closes post function
> > ); //
> closes ( after .post
> > } // closes {
> after
> > CalculateMortgage = function() {
> >
> > } // closes the submitHandler function
> >
> > }) // closes the ) before the .validate bracket?
> > }); // closes the .validate bracket
> >
> > </script>
> >
> >
> >
> > _______________________________________________
> > jQuery mailing list
> > [email protected]
> > http://jquery.com/discuss/
> >
> >
> >
> > _______________________________________________
> > jQuery mailing list
> > [email protected]
> > http://jquery.com/discuss/
> >
>
>
>
> --
> Aaron Heimlich
> Web Developer
> [EMAIL PROTECTED]
> http://aheimlich.freepgs.com
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
>
--
Ⓙⓐⓚⓔ - יעקב ʝǡǩȩ ᎫᎪᏦᎬ
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/