将数据库列值存储在javascript变量中

时间:2017-04-18 11:00:38

标签: javascript

我是javascript的新手,想要将数据库表中的列值存储到变量中以进行编辑。有人可以指导我该怎么做? 到目前为止我已经这样做了。

var itemName =$("product_id").find("product_id").text();
var qty = $("qty").find("qty").text();
var unit =$(this).find("UnitPrice").text();
var total =$("rate").find("rate").text();
var row = "<tr><td>" + itemName + "</td>" + "<td>" + qty + "</td>"+"<td>"+unit+"</td>" + "<td>" + total + "</td>" +
    "<td>" + "<a href='javascript:deleteLead(\"" + $(this).find("SalesLeadCode").text() + "\");' class=\"btn btn-danger\"><i class=\"glyphicon glyphicon-remove\"></i> Remove</a>" + "</td>";
$('#item_grid').append(row);

1 个答案:

答案 0 :(得分:0)

使用query localstorage解决您的问题,即使您也可以在其他页面上使用此数据。对于多个记录,您也可以使用循环。我希望它可以帮助你。

if (typeof(Storage) !== "undefined") {

    // Store
    var data = {};
    data.item_name = $("product_id").find("product_id").text();
    data.qty = $("qty").find("qty").text();
    data.var unit =$(this).find("UnitPrice").text();
    data.total =$("rate").find("rate").text();
    localStorage.setItem("data",data);  

    // Retrieve
    colsole.log(localStorage.getItem("data"));
}
else
{
    console.log("Sorry, your browser does not support Web Storage...");
}
相关问题