I have a form which includes adding operting time for a restaurant.
operation_hours(weekday, open_time, close_time, restaurant_id)
i use this in the form
<div class="operation_hours">
<?php echo $this->Form->dateTime('RestaurantOperationHour.open_time', false, '12', null, array('interval' => 15, 'value' => '10:00:00')); ?>
<?php echo "<label> to </label>"; ?>
<?php echo $this->Form->dateTime('RestaurantOperationHour.close_time', false, '12', null, array('separator' => ' ', 'interval' => 15, 'value' => '23:00:00')); ?>
</div>
which generates
http://pastebin.com/TDDesCRn
i wanna add multiple of this.. incase the rest works like this 10am to 3pm then 7pm to 11pm.
i will need to sets for a single day.
which is the best way to add this dynamically.
i tried some thing like this
// JavaScript Document
$(function () {
// Phone Number
var i = $('div#phoneContainer div input').size();
$('a#addPhone').click(function () {
$('<div><input name="data[Restaurantphone][' + i + '][number]" type="text" value="" id="Restaurantphone' + i + 'Number" /></div>').appendTo('div#phoneContainer');
i++;
});
// Restaurant Timing
var j = $('div#timeContainer div').size();
$('a#addTime').click(function () {
open_hours = $('div#timeContainer div select#Restauranttiming0OpenHour').html();
open_minutes = $('div#timeContainer div select#Restauranttiming0OpenMin').html();
open_meridian = $('div#timeContainer div select#Restauranttiming0OpenMeridian').html();
close_hours = $('div#timeContainer div select#Restauranttiming0CloseHour').html();
close_minutes = $('div#timeContainer div select#Restauranttiming0CloseMin').html();
close_meridian = $('div#timeContainer div select#Restauranttiming0CloseMeridian').html();
tag1 = '<select id="Restauranttiming';
tag2 = '" name="data[Restauranttiming][';
tag3 = '</select>';
open_hours = tag1 + j +'OpenHour' + tag2 + j + '][open][hour]">' + open_hours + tag3;
open_minutes = tag1 + j +'OpenMin' + tag2 + j + '][open][min]">' + open_minutes + tag3;
open_meridian = tag1 + j +'OpenMeridian' + tag2 + j + '][open][meridian]">' + open_meridian + tag3;
close_hours = tag1 + j +'CloseHour' + tag2 + j + '][close][hour]">' + close_hours + tag3;
close_minutes = tag1 + j +'CloseMin' + tag2 + j + '][close][min]">' + close_minutes + tag3;
close_meridian = tag1 + j +'CloseMeridian' + tag2 + j + '][close][meridian]">' + close_meridian + tag3;
content = '<div>\n' + open_hours + ':' + open_minutes + ' ' + open_meridian + '\n-\n' +close_hours + ':' + close_minutes + ' ' + close_meridian + '\n</div>';
$(content).appendTo('div#timeContainer');
j++;
});
});
i wanna know which the best way to do it with cakephp and jQuery ?