2013-03-17 120 views
1

我目前正在尝试更新一行的值 - 取决于使用jQuery的另一个值的行。根据另一个值的行更新一行中的值

例如:

如果房分配=待定那么按钮编辑和取消下出现操作 如果房分配=待定那么按钮编辑和衰落出现下操作

如何我会这样做吗?

这里是我已经包含了小提琴:http://jsfiddle.net/S9Gwy/

这是到目前为止我的代码:

$('.results_tbl').dataTable({ 
     "bPaginate": true, 
      "bLengthChange": false, 
      "bFilter": true, 
      "bSort": true, 
      "bInfo": false, 
      "bAutoWidth": true 
    }); 

     /*==================================== 

     determining whether cancel or decline 
     button is going to appear depending on 
     room allocation status 

     =====================================*/ 

    // find all the booking rows 

    var bookingRows = $('table tr.booking'); 

    // stash a reference to the row 

    bookingRows.each(function() { 
     var row = $(this); 

     // if you can add a class of 'pending' to the status <td>, this becomes even cleaner and nicer... 

     // check the contents of the status column 

     if (row.find('td.status').text().toLowerCase() == 'pending') { 

      // add a class to the row so the CSS can do its thing... 

      row.addClass('pending'); 
     } 
    }); 

回答

1

第一(行级)的解决方案可能是这样的:

tr.booking .cancelall { 
    display: none; 
} 

tr.booking.pending .cancelall { 
    display: inline-block; 
} 

tr.booking.pending .declineall { 
    display: none; 
} 
相关问题