Phil Famme
Phil Famme

Reputation: 119

Reset inputs after submit click

Thanks in advance for your help! I am asking users questions, and giving them input back. I want them to be able to do it again if they want, so i guess i want a reset button. I want to reset the input boxes, after the user hits submit. I have seen some really good answers to this question, but i would like to see a working example, after submit is clicked. It don't matter to me how i do it, if it's a href link that brings them to a sub domain and then back to the original one. Or if i make the input val "". My fiddle has some issues, I cut it apart quickly just so i can give a example of what i am trying to do. My input's come from a change function. My fiddle is below. If you pick the first option which is "Yes" it will work. Please if you can show a working example it will be very helpful.

$('.myOptions').change(function () {
$('.list').removeClass('active');
$('.' + this.value).addClass('active');
});


$('#butt').click(function () {
var ttta = $('.myOptions').val();
var tt = $('input[name=gender]:checked').val();
});

My html code:

<label>Please select an option :</label>
<select class="myOptions">
<option value="" selected>Pick an option</option>
<option value="owner">yes</option>
<option value="not-owner">no</option>

</select>

My fiddle http://jsfiddle.net/46tYs/8/

Upvotes: 1

Views: 296

Answers (2)

dfsq
dfsq

Reputation: 193261

You can make use of input[type="reset"]:

<input type='reset' id='reset' value='reset' />

http://jsfiddle.net/46tYs/11/

Upvotes: 0

tymeJV
tymeJV

Reputation: 104775

With your example I simply cleared the inputs and reset the select

$("#reset").click(function() {
    $("select").val("").change();
    $("input").val("");
});

Demo

Upvotes: 2

Related Questions