Click here to Skip to main content
15,881,700 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
This is my jquery script.

C#
<script type="text/jscript">
$(document).ready(function()
{

    var table = $("#TextBoxesGroup");
    var row = table.find("tr").eq(1);
    var count = 0;

    $("#addButton").click(function(e)
    {
        if (table.find("tr").length >= 10)
        {
            alert("Maximum 10 Item Only");
            return;
        }

        var newRow = row.clone();
        var regex = new RegExp("data\[[0-9]+\]", "g");
        newRow.html(newRow.html().replace(regex, "data[" + (++count) + "]"));
        table.append(newRow);
    });


    $(document).on('keyup', "*[data-field='quantity'],*[data-field='price']", function(e)
    {
        var thisRow = $(this).parents("tr:first");
        var rowTotalField = thisRow.find("*[data-field='total']");
        var price = parseFloat(thisRow.find("*[data-field='price']").val());
        var quantity = parseInt(thisRow.find("*[data-field='quantity']").val());
        rowTotalField.val("RM" + (!isNaN(price) && !isNaN(quantity) ?
                       price*quantity : 0).toFixed(2));
        var total = 0;
        table.find("*[data-field='total']").each(function()
        {
            var t = parseFloat($(this).val().replace("RM", ""));
            total += !isNaN(t) ? t : 0;
        });
        $("#total").text(total.toFixed(2));
    });

});
</script>
Posted
Comments
vbmike 19-Apr-14 11:25am    
That is a pretty big request but essentially you have to create a connection to a db, gather all your variables and validate the entries, write a sql statement, execute that statement on the db opened in your connection string. There are lots of examples on the net.
Azlina Ipran 20-Apr-14 12:45pm    
i already did but it only save data on the first row only.
vbmike 21-Apr-14 15:33pm    
Where did it save that row? In a mysql database, localDB? Without seeing what all the code you used did, if it only saved one row maybe you need a loop to go through the rows?
Sunasara Imdadhusen 8-May-14 6:13am    
Where is server side code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900