tags:

views:

47

answers:

2

So I'm using jquery to POST some items and save into the database. I have two optional fields, if they're not empty, I'd like to fadeIn in a related div in the success function. You'll notice the #picCheck.fadeIn. Right now that fades in if the stuff is submitted, but like i said, I'd like for it fadeIn only if the variable "picvault" from the submitted form has is set.

Here's the jquery:

$.ajax({
      type: "POST",
      url: "edit.php",
      data: $form.serialize(),
      success: function(){
       $('form#editForm').hide();
       $('div.success').center();
       $('div.success').fadeIn('slow').animate({opacity: 1.0}, 2000).fadeOut(1000);
       $('#picCheck'+sid).fadeIn('slow');
       }
     }); // End .ajax fucntion
A: 

Simply check the value of picvault in your callback function (assuming it's a checkbox)

if($("#picvault").is(":checked")) {
    $('#picCheck'+sid).fadeIn('slow');
}
Marek Karbarz
Thanks for the reply. The field isn't a checkbox, just a regular textbox. Basically, if we have pictures, we post a link in the textbox to where they're located. If that textbox isn't empty, i'd like to fadein
scatteredbomb
Thanks for your help, using your example I was able to use this code to get it workingif ( $("#picvault").val().length > 0 ) {
scatteredbomb
A: 

If you have access to the form, just put an if statement around your fadeIn code checking that value.

Myles