如何使用javascript从表列中的文本字段获取值

时间:2018-04-04 03:49:46

标签: javascript jquery yii

我在列中创建了一个带有输入文本字段的自动生成表。因此,所有输入文本字段id都相同。

$(document).on('click', '.oc-save-upgrade-downgrade-rules', function (event) {

    //sel - retrieve which row id was checked in checkbox
    var sel = $.fn.yiiGridView.getChecked('oc-list-upgradeRule', 'chkbox');

    //just a validation if non of the checkbox is check
    var row = $.fn.yiiGridView.getRow('oc-list-upgradeRule');

    //row - use row id to select entire row
    if (typeof sel !== 'undefined' && sel.length > 0){
        var row = $.fn.yiiGridView.getRow('oc-list-upgradeRule', sel);
    }

    //this has successfully get the value but always get the first row because all input text field use the same id
    var ipt = document.getElementById("indaysText").value;

    //currently this only able to retrieve a td segment, [5] means where the input text field are
    var input = $(row[5]);

    console.log(ipt);
    console.log(input);
})

目前使用此$(行[5]),我只能检索

<td style="text-align: center;">
     <input type="text" value="365" name="indays" id="indays">
</td>

它获取整个“td”,因此该值为null。我应该如何获得整个“输入”或直接获取输入值?

0 个答案:

没有答案