how to store dynamic added table row values in php mysql database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • noopursri
    New Member
    • Apr 2014
    • 1

    how to store dynamic added table row values in php mysql database

    Code:
    <HTML> <HEAD> <style type="text/css">
      #template {
     display: none;   
    }
    
    .add {
       margin: 5px;
       text-decoration: none;    
    }
    
      </style> <script type="text/jscript" src="http://example.com/New Folder/jquery-1.6.4.js"></script> <script type="text/javascript">
    var $k = jQuery.noConflict();
    
    $k.fn.sum = function() {
        var sum = 0;
        $k(this).each(function() {
            sum += parseFloat($k(this).val());
        });
    
        return sum;
    }
    
    $k(function() {
        $k('input[name^=quantity], input[name^=unitprice]').live("keyup", function() {
            var quantity = parseFloat($k(this).parent().find('input[name^=quantity]').val());
            var unitprice = parseFloat($k(this).parent().find('input[name^=unitprice]').val());
            $k(this).siblings('input[name^=linetotal]').val(quantity * unitprice);
    
            var sum = $k('input[name^=linetotal]').sum();
    
            $k('#subtotal').val(sum);
            $k('#tax').val(Math.round(sum * 10 * 100) / 100);
            $k('#total').val(Math.round((sum + Math.round(sum * 10 * 100) / 100) * 100) / 100);
        });
    
        $k('.add').live('click', function() {
            $k(this).closest('.item').after($k('#template').html());
            $k('form .item').each( function(i) {
            $k(this).find('input[name^=num]').val(i+1);
    		var q =$k('this').find('input[name^=num]').val();
    	    alert(q);
            });
        });
    });
    </script> </HEAD> <body> <div id="template"> <div class="item"> <input name="num" value="1" size="5"> <a href="http://example.com/submit/g/#" class="add">+</a> <input name="desc" value="Description"> <input name="quantity" value="0"> <input name="unitprice" value="0"> <input name="linetotal" value="0"> </div> </div> <form id="item_form"> <div class="item" > <input name="num" value="1" size="5"> <a href="http://example.com/submit/g/#" class="add">+</a> <input name="desc" value="Description One"> <input name="quantity" value="0"> <input name="unitprice" value="0"> <input name="linetotal" value="0"> </div> <div class="item" > <input name="num" value="2" size="5"> <a href="http://example.com/submit/g/#" class="add">+</a> <input name="desc" value="Description Two"> <input name="quantity" value="0"> <input name="unitprice" value="0"> <input name="linetotal" value="0"> </div> <div class="line">
            Subtotal: <input id="subtotal"> </div> </form> </body> </html>
    Last edited by Dormilich; Apr 9 '14, 11:06 AM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I don’t see a table anywhere.

    Comment

    Working...