Search Results

Search found 2 results on 1 pages for 'user559780'.

Page 1/1 | 1 

  • Adding dynamic data to a table

    - by user559780
    I've the following table in my application. I've a ajax request which will fetch the results to be shown in the table. How add these results to the table with out overridding the header every time? <table id="itemList"> <td>Name</td> <td>Price</td> <td>Quantity</td> <td>Total</td> </table> Then the ajax data is as shown below var items = [ { Name: "Apple", Price: "80", Quantity : "3", Total : "240" }, { Name: "Orance", Price: "50", Quantity : "4", Total : "200" }, { Name: "Banana", Price: "20", Quantity : "8", Total : "160" }, { Name: "Cherry", Price: "250", Quantity : "10", Total : "2500" } ]; Now I'm trying something like this but it is not working var rows = ""; $.each(items, function(){ rows += "<tr><td>" + this.Name + "</td><td>" + this.Price + "</td><td>" + this.Quantity + "</td><td>" + this.Total + "</td></tr>"; }); $( "#itemList" ).text('<tr><td>Name</td><td>Price</td><td>Quantity-</td><td>Total</td></tr>' + rows );

    Read the article

  • List of items with same values

    - by user559780
    I'm creating a list of items from a file BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("H:/temp/data.csv"))); try { List<Item> items = new ArrayList<Item>(); Item item = new Item(); String line = null; while ((line = reader.readLine()) != null) { String[] split = line.split(","); item.name = split[0]; item.quantity = Integer.valueOf(split[1]); item.price = Double.valueOf(split[2]); item.total = item.quantity * item.price; items.add(item); } for (Item item2 : items) { System.out.println("Item: " + item2.name); } } catch (IOException e) { reader.close(); e.printStackTrace(); } Problem is the list is displaying the last line in the file as the value for all items.

    Read the article

1