I want to create a simple function to reset all input values without target input. (Javascript, Jque

Posted by question_about_the_problem on Stack Overflow See other posts from Stack Overflow or by question_about_the_problem
Published on 2010-05-09T13:52:33Z Indexed on 2010/05/09 13:58 UTC
Read the original article Hit count: 162

Filed under:
|

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');">

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript