Javascript计数器不工作

时间:2014-05-25 20:45:52

标签: javascript asp.net

计数器不工作在此代码中。提供任何示例。我的代码在

下面
 var rnos = jQuery("#ContentPlaceHolder1_hdnf").val(); //Get 1 value From c#

    function getProducts() {
        alert(jQuery("#ContentPlaceHolder1_hdnf").val());
        var decode = jQuery("#hdnfield").val();

        //  var decode = "7503960000";
        $.getJSON("http://localhost:8244/api/FRecharge?rno=" + rno + "&id=" + decode,
            function (data) {
                $('#products').empty(); // Clear the table body.

                // Loop through the list of products.
                $.each(data, function (key, val) {
                    // Add a table row for the product.
                    var row = '<td>' + val.status + '</td>';
                    $('<tr/>').html(row)  // Append the name.
                        .appendTo($('#products'));

                });
            });

        rnos = rnos + 1; 
        $("#ContentPlaceHolder1_hdnf").val()=$("#ContentPlaceHolder1_hdnf").val(rnos);//Increment Value and assign to Hidden field
    }

= - = - = - = - = - === -

我已经尝试过了:

$( “#ContentPlaceHolder1_hdnf”)VAL()= $( “#ContentPlaceHolder1_hdnf”)VAL(RNOS); // 和 $( “#ContentPlaceHolder1_hdnf”)。VAL(RNOS)

警报始终显示1。

1 个答案:

答案 0 :(得分:0)

Thnx Guys我得到答案(增加隐藏字段中的值。我在页面加载时设置0值)

 var startElement = $("#ContentPlaceHolder1_hdnf");
 var value = parseInt(startElement.val());
 alert(value);
 //startElement.val(value + 1);
 var rnos = startElement.val(value + 1);
 //alert(rnos);`