如何将Jquery值传递给asp.net中的代码

时间:2015-03-04 08:13:15

标签: javascript jquery asp.net

 $("#getButtonValue").click(function () {
            var msg = '';
            for (i = 1; i < counter; i++) {
                msg += "\n Width #" + i + " : " + $('#txtWidth' + i).val();
                msg += "\n Height #" + i + " : " + $('#txtHeight' + i).val();
                msg += "\n Length #" + i + " : " + $('#txtLength' + i).val();
                msg += "\n Weight #" + i + " : " + $('#txtWeight' + i).val();
            }
            alert(msg);
        });

此代码多次返回高度,宽度,长度和重量(相对于conter)。

enter image description here

我想将所有这些值传递给文件后面的代码。并将所有值传递给此包。

                qurystr += "&packages[1][width]=" ";
                qurystr += "&packages[1][height]="";
                qurystr += "&packages[1][length]="";
                qurystr += "&packages[1][weight]="";

请帮忙。谢谢

1 个答案:

答案 0 :(得分:0)

您可以使用隐藏字段将列表另存为逗号分隔值

<asp:HiddenField runat="server" id="hdf" />

在JS中

$('<%#hdf.CliendID%>').value="1,2,3,4,5,6,7,8,9";

width,height,length,width,height,length....