【问题标题】:not able to get particular text box value using jquery无法使用 jquery 获取特定的文本框值
【发布时间】:2021-12-30 08:27:25
【问题描述】:

这是我的 jquery 函数。我在蓝色事件上调用此函数。列表中有多个记录。我想在模糊事件中获得特定的 rojmel_id 和权重,但我无法获得。谁能帮我解决这个问题。

<script type="text/javascript">
function getweight(thisObj)
{
    var row        = $(thisObj).parents('.row');
    var rojmel_id  = row.find('.rojmel_id').val() != '' ? row.find('.rojmel_id').val() : 0;
    var dataString = "rojmel_id=" + rojmel_id;
    
    $.ajax({
        type: "POST",
        url: "updateWt.php",
        data: dataString,
        success: function (data){
      }
    });
}
</script>

这是我的html代码

{section name=sec loop=$clientArray}
    <tr>
     <td>{$clientArray[sec].rojmel_date}</td>
     <td>{$clientArray[sec].party_name}</td>
     <td>{$clientArray[sec].item_nm}</td>
     <td>{$clientArray[sec].marko}</td>
     <td><input type="hidden" class="rojmel_id" name="rojmel_id" value="{$clientArray[sec].rojmel_id}">
     <input type="text" name="weight" value="{$clientArray[sec].weight}" onblur="getweight(this);"></td>
    </tr>
{/section}
</tbody>

【问题讨论】:

    标签: php jquery


    【解决方案1】:

    试试这个希望它有效!你能告诉你在哪里被声明为 .row 类吗?

    这是您的解决方案:Solution JSBin

    <!-- add class to <tr> then --> 
    
    {section name=sec loop=$clientArray}
        <tr class="row">
         <td>{$clientArray[sec].rojmel_date}</td>
         <td>{$clientArray[sec].party_name}</td>
         <td>{$clientArray[sec].item_nm}</td>
         <td>{$clientArray[sec].marko}</td>
         <td><input type="hidden" class="rojmel_id" name="rojmel_id" value="{$clientArray[sec].rojmel_id}">
         <input type="text" name="weight" value="{$clientArray[sec].weight}" onblur="getweight(this);"></td>
        </tr>
    {/section}
    </tbody>
    
    <script type="text/javascript">
    function getweight(thisObj)
    {
        var row        = $(thisObj).closest('tr.row');
        var rojmel_id  = row.find('.rojmel_id').val() ? row.find('.rojmel_id').val() : 0;
        var dataString = "rojmel_id=" + rojmel_id;
        
        $.ajax({
            type: "POST",
            url: "updateWt.php",
            data: dataString,
            success: function (data){
          }
        });
    }
    </script>

    【讨论】:

    • 有了这个我可以得到 Id But Still Bot weight 值。在文本框中输入。
    • 它正在工作,兄弟,非常感谢......
    • @PrashantOmVir NP!
    猜你喜欢
    • 2016-02-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-02
    • 1970-01-01
    • 2016-01-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多