I want to create a simple function to reset all input values without target input. (Javascript, Jque
- by question_about_the_problem
Hi,
I want to create a simple function to reset all input values without target input.
I don't know how i can do it.
Thanks.
Here is my sample codes:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
function reset_other_inputs(room) {
$("input[name^='check_in_date_']").each(function () {
if ( $("input[name!='check_in_date_'+room]") ) { this.val(""); }
});
$("input[name^='check_out_date_']").each(function () {
if ( $("input[name!='check_out_date_'+room]") ) { this.val(""); }
});
}
</script>
<input type="text" name="check_in_date_single" value="single" onClick="reset_other_inputs('single');">
<input type="text" name="check_out_date_single" value="single" onClick="reset_other_inputs('single');">
<input type="text" name="check_in_date_double" value="double" onClick="reset_other_inputs('double');">
<input type="text" name="check_out_date_double" value="double" onClick="reset_other_inputs('double');">
<input type="text" name="check_in_date_triple" value="triple" onClick="reset_other_inputs('triple');">
<input type="text" name="check_out_date_triple" value="triple" onClick="reset_other_inputs('triple');">
<input type="text" name="check_in_date_suite" value="suite" onClick="reset_other_inputs('suite');">
<input type="text" name="check_out_date_suite" value="suite" onClick="reset_other_inputs('suite');">