I have a form where I want an optional field to be cleared if the user changes his/her choice. I got the form to add or remove the optional option, but if the user type in text in the optional field, and then changes his/her mind, and hit the cancel button, then I want the value in the optional field to be cleared. I need this because when the form is submitted, it is important that the optional field is empty if no new date from the optional field is ment to be submitted to the database.
<form>
<a href="#" class="show_hide">+ Add New</a>
<div class="slidingDiv">
Artists name: <input type="text" name="name">
Artists info: <textarea name="info" cols="65" rows="15"></textarea>
<a href="#" class="show_hide">Cancel</a>
</div>
</form>
-
$(document).ready(function(){
$(".slidingDiv").hide();
$(".show_hide").show();
$('.show_hide').click(function(){
$(".slidingDiv").slideToggle();
});
});