Holy @!$! that was fast. Thanks guys,

This is all in doc.ready. If I move the regular functions out, I
cannot use the 'olde' var in them. If I set the 'olde' var outside of
doc.ready, I can't use it inside doc.ready.

I'm sure there is a simple fix for this but the little grey cells are
smoking already.


[code]

// get the original email address for comparison
var olde = $('#editaemail').val();

// Define global error vars
var emailerror = 0;
var passworderror = 0;




// Save button on form starts the whole thing
$('#editasave').click(function(){
        newe = $('#editaemail').val();
        url = '/myaccount/process.cfm?t=' + new  Date().getTime();
        $('#editasave').attr("disabled","disabled").attr("value","One
Moment");
        if(olde != newe){
                $('#editasave').attr("value","Checking Email");
                $.post(url, {checkname: newe}, chkmail, "json");
        }
        else{
                $('#emailerror, .emailerror').hide();
                emailerror = 0;
                checkeditapass();
        }
});


// Checks the results of the post call to see if the email already
exists in the DB
// Displays error information and sets appropriate vars in the case of
an error
function chkmail(data){
        if (data.exists == 1){
                $('#emailerror, .emailerror').show();
                emailerror = 1;
        }
        else{
                $('#emailerror, .emailerror').hide();
                var olde = $('#editaemail').val();
                emailerror = 0;
        }

        //These always cause an 'undefined' error when the function is
included within doc.ready
        setTimeout("checkeditapass()", 2000);

}

// Checks the password fields to make sure they are the same
// Displays error information and sets appropriate vars in the case of
an error
function checkeditapass(){
        $('#editasave').attr("value","Checking Passwords");
        p1 = $('#editapassword1').val();
        p2 = $('#editapassword2').val();

        if (p1 != p2){
                $('#passerror, .passerror').show();
                passworderror = 1;
        }

        else{
                $('#passerror, .passerror').hide();
                passworderror = 0;
        }

        //These always cause an 'undefined' error when the function is
included within doc.ready
        setTimeout("checkeditavars()", 2000);

}

// Checks the global error vars and only submits the form if there are
no errors
function checkeditavars(){
        if(emailerror == 0 && passworderror == 0) {
                $('#editasave').attr("value","Saving Changes");
                setTimeout("sendit()", 2000);
        }

        else
        {
                $('#editasave').removeAttr("disabled").attr("value","Save 
Changes");
        }
}

// Actually sends the form data through form plugin and unblocks the
UI
function sendit(){
        $('#editaform').ajaxSubmit(function(){
                $('#editasave').attr("value","Changes Saved");
                url = '/myaccount/process.cfm?getdetail=1&t=' + new  
Date().getTime
();
                $('#accountcontent').load(url, function(){
                        $.unblockUI();
                });
        });
}
[/code]

Reply via email to