Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在keypress上获取以html表为中心的特定于行的列数据_Javascript_Jquery_Html Table_Row - Fatal编程技术网

Javascript 如何在keypress上获取以html表为中心的特定于行的列数据

Javascript 如何在keypress上获取以html表为中心的特定于行的列数据,javascript,jquery,html-table,row,Javascript,Jquery,Html Table,Row,我希望根据按键事件获取特定列值。我为恢复成本列指定了按键事件。根据回收成本条目,我必须获取标准费率并比较数值。如果恢复成本大于标准速率,则显示一条警报消息 功能: <td> <input type="text" runat="server" id="txtStdRate" value='<%# Eval("std_rt")%>'/></td> <td

我希望根据按键事件获取特定列值。我为恢复成本列指定了按键事件。根据回收成本条目,我必须获取标准费率并比较数值。如果恢复成本大于标准速率,则显示一条警报消息

功能:

<td> 
<input type="text" runat="server" id="txtStdRate" value='<%# Eval("std_rt")%>'/></td>                                             
<td>
<input type="text" runat="server" id="txtRcvryCost" value='<%# Eval("recovery_cost")%>'onkeypress='return isNumberKey(event)'/>
 </td> 


**......................**

    function isNumberKey(evt) {
           var charCode = (evt.which) ? evt.which : evt.keyCode;
           if (charCode != 46 && charCode > 31
           && (charCode < 48 || charCode > 57))
              return false;

           return true;
          }

**......................**
函数isNumberKey(evt){
var charCode=(evt.which)?evt.which:evt.keyCode;
如果(charCode!=46&&charCode>31
&&(字符编码<48 | |字符编码>57))
返回false;
返回true;
}

要进行验证,必须添加onKeyUp: 请尝试以下操作:

    <td>
        <input type="text" runat="server" id="Text3" value='<%# Eval("std_rt")%>' />
    </td>
    <td>
        <input type="text" runat="server" id="Text4" value='<%# Eval("recovery_cost")%>'
            onkeypress='return isNumberKey(event)' onkeyup="checkWithStdrate(event);" />
    </td>

您好,这对相邻的柱起作用。我想比较第五栏和第七栏。请查看我发布的带有上述问题的图片。那么如何更改“parseInt($(evt.target).parent().prev().find(“input”).val());”您可以将prev()添加到左一列,或将next()添加到右一列。示例:以下内容将此列值与此列剩余三列的列进行比较-parseInt($(evt.target).parent().prev().prev().prev().prev().find(“input”).val()
    function checkWithStdrate(evt) {
        var prevTextBox = parseInt($(evt.target).parent().prev().find("input").val());
        var thisTextBox = parseInt($(evt.target).val());

        if (thisTextBox > prevTextBox) {
            alert("Error Message");
            return false;
        }

        return true;
    }