Hi folks,

I'm hoping someone might paint me a picture of how to use jQuery's equivalent of if/then conditional statements - or how to arrange jQuery code to allow for such.

I have the following code which collects information from an email form and sends it to the server for processing.  If the form information is complete, the email is sent, and the client-side form has the values of its textarea element set to nothing, and the form itself is made to disappear.

My problem is that if the form is not sent for some reason (e.g. a valid address is not given), I don't want the textarea element to be reset or the form hidden.

Can someone please give me a conceptual framework/(pseudo-code) example of how to approach this situation?

Thanks,

Bruce

The code below is how I am achieving the first scenario (when the information from the email form is all OK and the email is sent after server-side processing)

$.fn.ajaxSubmitEmail = function(e) {this.submit(function(){ var params = {}; $(this) .find("[EMAIL PROTECTED], [EMAIL PROTECTED]'text'], [EMAIL PROTECTED]'hidden'], [EMAIL PROTECTED], textarea") .filter(":enabled") .each(function() { params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value; });$("div#indicate").show(); $.post(this.getAttribute("action"), params, function(text){
    $("div#indicate").hide();
    $('textarea', "emailform").val('');
    $("div#email").slideUp('fast');
    $("div#thereply").html(text).slideDown('slow').highlightFade({color:'yellow',speed:2000,iterator:'sinusoidal'});
    }); return false; });}
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to