Reputation: 11
I am selecting time slot on dragging on time slot cell. After selecting time slot, I enter patient name in textbox and click on select button then patient name goes to selected time slot. The user can select multiple time slot for multilpe patient name and onclick of allot button I have to insert patient name with time slot (From time To time) to database.
I have problem in getting alloted time slot ie.From time and To time in jquery.
$("#btnAllot").click(function () {
//how i get alloted time here.
$('tr').each(function () {
$(this).find('td').each(function () {
if ($(this).hasClass('yell')) {
alert($(this).closest('tr').find('td:eq(1)').text());
};
});
});
}
I have used above but get only minute not patient name, hour. see live jsbin demo here see fiddle
Upvotes: 0
Views: 644
Reputation: 3956
You only get minute because you only pick Time Slot column value, see updated fiddle:
$("#btnAllot").click(function() {
$('tr:gt(0)').each(function() {
if ($(this).has("td[class='yell']")){
var hour = $(this).find('td:eq(0)').text();
var slot = $(this).find('td:eq(1)').text();
var name = $(this).find('td:eq(2)').text();
var msg = 'Hour: ' + hour + ' Slot: ' + slot + ' Name: ' + name;
alert(msg);
}
});
});
Upvotes: 1