I have little form with a couple of check boxes and a hidden div which opens when user check corresponding box. I want to use ajax and json to insert the data in database when speccific date is checked and to insert time in database inserted from hidden div. Is it possible? Here is my form: ON jsFiddle
<div>
<input type="checkbox" name="monday" id="mon" class="toggler" /> Monday
<input type="checkbox" name="tuesday" id="tue" class="toggler" />Tuesday
<input type="checkbox" name="wendsday" id="wen" class="toggler"/> Wendsday
<input type="checkbox" name="thursday" id="thu" class="toggler" /> Thursday
<input type="checkbox" name="friday" id="fri" class="toggler" /> Friday
<input type="checkbox" name="saturday" id="sat" class="toggler" /> Saturday
<input type="checkbox" name="sunday" id="sun" class="toggler" /> Sunday
</div>
<div id="name" class="hidden" style="display: none">
Time From::<input type="text" id="place" placeholder=""></input> Time To::<input type="text" id="place_one" placeholder=""></input>
<input type="button" onclick="save_time();" value="Save" />
</div>
Here is my javascript:
$(function(){
$('.toggler').click(function(id){
if (this.checked) {
$('#name').slideDown();
} else {
$('#name').slideUp();
}
});
save_time = function(days){
$.ajax({
type: "post",
url: "",
data: "days="+days,
success: function(data){
}
});
$('#name').slideUp();
};
});