JSFiddle - React, Tailwind, and code Playground
HTML
<p>put some values in these fields and watch how the object doesn't update (at least not for me) :(</p>
<input type="text" class="roomrequest no_hotel" name="no_hotel_[2011-08-21]" value="0" />
<input type="text" class="roomrequest no_hotel" name="no_hotel_[2011-08-22]" value="0" />
<input type="text" class="roomrequest no_hotel" name="no_hotel_[2011-08-23]" value="0" />
JavaScript
$(document).ready(function(){
var hotelBooking = {};
$(".roomrequest").blur(function()
{
updateHotelBooking();
});
function updateHotelBooking()
{
$(".no_hotel").each(function(i) {
var day = $(this).attr('name').match(/\[(.*?)\]/)[1];
hotelBooking["key_" + day] = parseInt($(this).val());
console.log(hotelBooking);
});
}
});