Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.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.
JavaScript
  $("#btnAllot").click(function ()
                {
//how i get alloted time here.
                }

see live jsbin on dragging on time slot cell
Posted
Updated 23-Jun-12 4:44am
v2

1 solution

Uniquely identifying the time/patient record is important. This becomes obscured when you alter the rowspan of the name.

Below is the code I used:
Note: I added a class called "time" to the time elements and added a div element to contain the resultant html called "container".

JavaScript
$("#btnAllot").click(function ()
{
   var container = $("#container");
   var times = $("td.yell.time");
   var html = "";
              
   container.empty();
   for(var i = 0; i < times.length; i++)
   {
      html += $(times.get(i))
         .parent(".csstablelisttd").get(0).outerHTML;
   }
   container.html(html);

});


First I get all of the "time" td's that have a corresponding patient (identified by "yell"). Then I iterate over these items:

In the iteration, first the current "time" td is retrieved by the index "i". I then get it's "csstablelisttd" parent. This allows you to obtain a list of "csstablelisttd" elements that contain a time/patient value pair. With this, you can parse into an object and pass to the web server.

You would probably add the time and patient to a time/patient object array like so:

http://jsfiddle.net/rEvBp/
 
Share this answer
 
Comments
[no name] 6-Aug-12 1:13am    
Caleb:
on click of allot button getting undefined undefined undefined have u chk the fiddle.how get from time and to time in alert box whenever i click on allot button.
Caleb McElrath 6-Aug-12 9:14am    
Thats interesting, the jsfiddle link I sent you works just fine for me. Like I said before, the uniqueness of a row is obscured when you alter the rowspan of the name (patient) column so you will have to account for that. Also look at the jsfiddle link at the end of the solution. This link works in IE and Chrome.
[no name] 6-Aug-12 9:23am    
caleb: u display only minute what about hour
[no name] 6-Aug-12 9:25am    
i want time like this if user drag time from 8:15 to 8:45 then i want in alert box Fromtime 8:15 Totime 8:45.. did u understand or not if no then i will again explain u
[no name] 6-Aug-12 9:27am    
and also i m not able to see html in jsfidle can u pls do in jsbin

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900