找到表格中的复选框,然后选中输入键按下复选框

时间:2017-08-04 16:57:47

标签: php jquery mysql

如何关注突出显示的行复选框和输入键,选中复选框。 当我点击输入所有复选框被选中但我想检查突出显示的行的复选框。 i want this highlighted row's checkbox to be checked on enter key press

<tbody id="navTable">
<tr class="lastRow" id="start">
  <td>
  <div class="checkbox">
    <label><input type="checkbox" id="selectedProduct" name="selectBox" value="<?php echo ucfirst($row['pid']); ?>"></label>
  </div>
  </td>
  <td><?php echo ucfirst($row['Product_Name']); ?><input type="text" name="productName[]" value="<?php echo ucfirst($row['Product_Name']); ?>" hidden="true"></td>
  <td><input type="text" name="pPrice" value="<?php echo ucfirst($row['Product_Price']); ?>" hidden="true"><?php echo $row['Product_Price']; ?></td>
  <td><input type="text" name="pStack" value="<?php echo ucfirst($row['Product_Stack_No']); ?>" hidden="true"><?php echo $row['Product_Stack_No']; ?></td>
  <td><input type="text" value="<?php echo ucfirst($row['Product_Purchased']); ?>" hidden="true"><?php echo ($row['Product_Purchased'] - $row['Product_Sold']); ?></td>
  <td><input type="text" value="<?php echo ucfirst($row['Product_GST_Rate']); ?>" hidden="true"><?php echo $row['Product_GST_Rate']."%"; ?></td>
  <td><input type="text" value="<?php echo ucfirst($row['Product_Purchase_Date']); ?>" hidden="true"><?php echo $row['Product_Purchase_Date']; ?></td>
  <td><input type="text" value="<?php echo ucfirst($row['Product_Expiry_Date']); ?>" hidden="true"><?php echo $row['Product_Expiry_Date']; ?></td>
</tr>

window.displayBoxIndex = -1;
    var Navigate = function (diff) {
        displayBoxIndex += diff;
        var oBoxCollection = $("#navTable tr");
        if (displayBoxIndex >= oBoxCollection.length) {
            displayBoxIndex = 0;
        }
        if (displayBoxIndex < 0) {
            displayBoxIndex = oBoxCollection.length - 1;
        }
        var cssClass = "navBox";
        oBoxCollection.removeClass(cssClass).eq(displayBoxIndex).addClass(cssClass);
    }
    $(document).on('keypress keyup', function (e) {
        if (e.keyCode == 13) {
            //alert("hello");
            $('.navBox').trigger('click');
            $("input:checkbox").click();
            return false;
        }
        if (e.keyCode == 40) {
            //down arrow
            Navigate(1);
        }
        if (e.keyCode == 38) {
            //up arrow
            Navigate(-1);
        }
    });

0 个答案:

没有答案