0

I am new in javascript and want to store column value from database table into a variable for the purpose of editing. can some one guide me how should i perform this? I have done this so far.

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);
Komal12
  • 3,340
  • 4
  • 16
  • 25
  • have a look on this and see how to query database from javascript: http://stackoverflow.com/questions/857670/how-to-connect-to-sql-server-database-from-javascript-in-the-browser – Jahangir Alam Apr 18 '17 at 11:12
  • try this one to store data in database from javascript: http://stackoverflow.com/questions/11027982/how-to-get-data-from-database-in-javascript-based-on-the-value-passed-to-the-fun – Jahangir Alam Apr 18 '17 at 11:13

1 Answers1

0

use query localstorage for your problem, even you can use this data on other page also. for multiple records you can use looping also. I hope it helps you.

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...");
}
HirenMangukiya
  • 645
  • 3
  • 13
  • 30