HTML and jQuery – Reset a form. How?

I’m working on a PHP + HTML + jQuery project. And there are quite some coding knowledge problem I faced during my way of coding – But I’m almost done with it! To get it done, I just need this last help (for this project for sure) to get done.So, what I need is to RESET a …

via HTML Language Development » Search Results » ajax:

HTML and jQuery – Reset a form. How?

I’m working on a PHP + HTML + jQuery project. And there are quite some coding knowledge problem I faced during my way of coding – But I’m almost done with it! To get it done, I just need this last help (for this project for sure) to get done.
So, what I need is to RESET a form using jQuery after this:
1) I have a form that includes a and a to submit the form (not type=”submit”, since I’m using jQuery Ajax to submit the form)
2) I hit the button to make the form send and give back some information using a jQuery plugin etc.
3) I get the results in the same page as you might have understood. And using jQuery, I make a button that says RESET available, to reset everything I just did using Ajax.
4) The RESET button has to do the following code:
$(‘#remote-reset’).live(‘click’, function() // The reset button

$(‘#remoted’).slideUp(‘fast’, function() $(‘#remoted’).empty(); ); // the div that is seen after Ajax submitting the form
$(this).hide(); // hide this button when I click it
$(‘#remote-start’).show(); // see the again
$(‘#remote-urls’).empty(); // empty the textarea
$(‘#remote-upload’).resetForm(); // reset the form using a jQuery plugin, doesn’t work at all
});5) I click the RESET button and it does all above, but it wont do the most important thing: It’s not making it possible to SEND a new form again with other information in the WITHOUT refreshing the page. $(‘#remote-start’).show(); would have to SEND the form again, but I simply click over it and nothing happens.
So, in short words: I send a form with information -> Get results -> Hit reset -> Form is all cleared -> Put in new information -> Hit Submit -> Nothing happens.
Why would this happen and what would be the solution? Ideas?
EDIT (Submit button code):
$(‘#remote-start’).click(function()

$(‘#loader1′).show();
$(this).hide();
$(‘#remote-reset’).show();
$(‘#remote-upload’).ajaxSubmit(

success: function(response)

$(‘#remoted’).html(response).hide().slideDown(‘fast’);
$(‘#loader1′).fadeOut(‘normal’);

});
});HTML Code:

…………………………………..

Maybe you are resetting fields not supposed to be reseted – Like values in hidden inputs. It would really help out if you provide the html code.
But if you want to have better control of the fields that you need to reset, you can do like this:
$(“input[type=text], textarea”).val(“”)That would reset all input with type=”text” and all textarea tags.
edit
Oh, and by the way. You need to use live, and not click if you are replacing the content where the element with id #remote-start is. Because, if you don’t the event won’t get triggered when re-submitting.
Basically
$(‘#remote-start’).click(function()needs to be replaced with
$(‘#remote-start’).live(‘click’, function()
…………………………………..

See this question/answer to see how to reset without the plugin:
Blank out a form with jQuery
The problem is probably caused by the resetForm plugin you’re using, probably “die”ing the events or attributes on the form or something.
…………………………………..

Try to make it as live click
$(‘#remote-start’).live(‘click’,function()…..);

For more info: HTML and jQuery – Reset a form. How?

HTML Language Development » Search Results » ajax

HTML and jQuery – Reset a form. How?

Share this post:

Related Posts

Leave a Comment