Getting undefined on button click (textbox value)

问题: I'm trying to pass value to the edit form on Edit button click (Anchor tag). When i'm alerting it it gives me undified in alert. When i'm alerting Charector value it shows...

问题:

I'm trying to pass value to the edit form on Edit button click (Anchor tag). When i'm alerting it it gives me undified in alert. When i'm alerting Charector value it shows proper result, but not for ID's.

here is my code:

<a href="javascript:void(0);" class="btn btn-info btn-sm item_edit" data-statusCode="'+data[i].statusCode+'" data-status="'+data[i].status+'">Edit</a>

data[i].status in alert gives me Status value, but data[i].statusCode gives Undified. As in Image I'm getting values in response.

enter image description here

My Edit code:

//get data for update record
    $('#showList').on('click','.item_edit',function(){
        var statusId = $(this).data('statusCode');
        var status = $(this).data('status');

        $('#Modal_Edit').modal('show');
        alert(statusId);
        $('[name="statusId_edit"]').val(statusId);
        $('[name="status_edit"]').val(status);

    });

Any kind of help is welcome, thanks in advance.


回答1:

The issue is with camel case in your data-statusCode attribute.

Change data-statusCode="'+data[i].statusCode+'"

to data-status-code="'+data[i].statusCode+'"

  • 发表于 2019-03-19 09:56
  • 阅读 ( 116 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除