SHARE
TWEET

Untitled

a guest Feb 19th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <tr>
  2. <td>
  3.     <ol start="1" class="selectable">
  4.         <li class="ui-widget-content">0800 - 0830</li>
  5.         <li class="ui-widget-content">0830 - 0900</li>
  6.     </ol>
  7. </td>
  8. <td>
  9.     <ol start="1" class="selectable">
  10.         <li class="ui-widget-content">0800 - 0830</li>
  11.         <li class="ui-widget-content">0830 - 0900</li>
  12.     </ol>
  13. </td>
  14.    
  15. <script>
  16. $(function() {
  17.     $( ".selectable" ).selectable({
  18.         stop: function() {
  19.  
  20.             $(".selectable li").css({"background":"white","color":"black"});
  21.  
  22.             var result = $( "#select-result" ).empty();
  23.             var bookingHours = $( "#booking-hours" ).empty();
  24.             var bookingPeriod = [];
  25.             var count = 0;
  26.  
  27.  
  28.             $( ".ui-selected", this ).each(
  29.                 function() {
  30.                     $( this ).css({"background":"#F39814","color":"white"});
  31.                     var index = $( ".selectable li" ).index( this )+1;
  32.                     bookingPeriod[count] = index;
  33.                     count++;
  34.                 }
  35.             );
  36.             bookingHours.append( (count*0.5) + " Hours" );
  37.  
  38.             var bookingFrom = bookingPeriod[0];
  39.             var bookingTo = bookingPeriod[bookingPeriod.length-1];
  40.  
  41.             result.append( ( bookingFrom ) + " to " + ( bookingTo ) );
  42.         }
  43.     });
  44. });
  45. </script>
  46.    
  47. var index = $( ".selectable li", $(this).parent() ).index( this )+1;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top