+2  A: 

You can do all this in jQuery, not necessarily simpler, but a bit cleaner overall, like this:

$(function() {
  $("input[name^='check_in_date_'], input[name^='check_out_date_']").click(function() {
    var room = $(this).attr("name");
    room = room.substring(room.lastIndexOf("_") + 1);
    $("input[name='check_in_date_" + room +"'], input[name='check_out_date_" + room +"']").not(this).val('');
  });
})​​​​​​;​

Remove your inline onClick handler for this approach, you can see a working demo here.

Nick Craver
I want to clear other values, not the target value.
question_about_the_problem
@question_about_the_problem - Sorry, your original code did :) Updated the answer and the example demo to not clear the one you clicked on.
Nick Craver
A: 

OK! Finally I've found the solution;

function reset_other_inputs(room) {
 $("input[name^='check_in_date_']").each(function () {
     if ( $(this).attr("name") != "check_in_date_"+room) { $(this).val(""); }   
 });
 $("input[name^='check_out_date_']").each(function () {
     if ( $(this).attr("name") != "check_out_date_"+room) { $(this).val(""); }   
 });
}

Thanks for your answers.

question_about_the_problem
A: 

That seems to work I was actually going to suggest this solution:

var $relevantInputs = $('input[name^=check_in_date]')
                  .add('input[name^=check_out_date]');
$relevantInputs
    .click(function() {
        var $thisInputsValue= $(this).val();
        reset_other_types($thisInputsValue);
    });

function reset_other_types(type) {  
   $relevantInputs
        .filter(':not([value=' + type + '])')
            .val("")
        .end();
}

The first two lines grab the relevant inputs (in case there's many on the page). The second line applies a click handler to all of the relevant inputs (remember that jQuery uses implicit iteration, so the click handler is applied to all objects that were matched in the above two lines). Within the click handler (the user has clicked an input) we get the value of the input that the user has clicked and pass it to the reset_other_types function. This function basically resets the value of all the relevant inputs that do not match the one given in the type parameter. Disco! Readable, unobtrusive solution (which means you don't have to maintain all those fugly separate click handlers in the HTML :P). Cheers!

Mohammad Ashour