Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.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 在jqGrid中单击按钮时如何检索textbox的单元格内容?_Javascript_Jquery_Jqgrid - Fatal编程技术网

Javascript 在jqGrid中单击按钮时如何检索textbox的单元格内容?

Javascript 在jqGrid中单击按钮时如何检索textbox的单元格内容?,javascript,jquery,jqgrid,Javascript,Jquery,Jqgrid,在我的jqGrid中,我有一个文本框和按钮。我需要保存用户在单击该按钮时键入的文本框的值。我已经试过了,但是没有得到结果 以下是我的colModel: { name: 'Price', index: 'Price', width: 120, editable: true, edittype: "text", formatter: generateTextBox }, { name: 'Checkout', index: 'Checkout', width: 120, editable: true

在我的jqGrid中,我有一个文本框和按钮。我需要保存用户在单击该按钮时键入的文本框的值。我已经试过了,但是没有得到结果

以下是我的colModel

{ name: 'Price', index: 'Price', width: 120, editable: true, edittype: "text", formatter: generateTextBox },
{ name: 'Checkout', index: 'Checkout', width: 120, editable: true, formatter: generateCheckoutBtn }
我已经编写了自定义格式化程序来生成文本框和按钮,代码如下

function generateTextBox(cellvalue, options, rowObject) {
        return '<input type="text" size="10" maxlength="15" />';
    }
函数返回正确的rowId,使用alert进行检查,但它返回txt的alert作为

<input type="text" size="10" maxlength="15" />

我不知道如何获取用户在文本框中键入的单元格内容,然后将其保存到数据库中。此外,当用户在未键入文本的情况下单击“签出”按钮时,我必须发出一个警报


任何帮助都将不胜感激

对于输入,也许你可以给它起个名字

<input type="text" size="10" maxlength="15" name="yourtxtboxname" />


然后使用名称传递它

您必须用唯一ID区分每个单独的文本框。将文本框ID与格式化程序中的行ID连接起来:

function generateTextBox(cellvalue, options, rowObject) {
    return "<input type=\"text\" size=\"10\" maxlength=\"15\" id=\"textbox" + options.rowId + "\"/>";
}

小提琴会很好地解决这个问题。
<input type="text" size="10" maxlength="15" name="yourtxtboxname" />
function generateTextBox(cellvalue, options, rowObject) {
    return "<input type=\"text\" size=\"10\" maxlength=\"15\" id=\"textbox" + options.rowId + "\"/>";
}
function getTextBoxValue(SelectedId) {            
    alert("RowId: " + SelectedId);
    var txt = $("#textbox" + SelectedId).val();
    alert("" + txt);
}