Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(){
- $("#nuevo_ingrediente").click(function(){
- var c = $("tr:last td", $("#tabla-porciones")).length;
- var rw = $("tr:gt(0)", $("#tabla-porciones")).length;
- var row = "<tr>";
- for(var i = 0; i< c; i++){
- col_i = i - 1;
- if(i == 0){
- row += "<td><input type=\"text\" maxlength=\"128\" name=\"ingredientes[]\" id=\"edit-0\" value=\"\" class=\"form-text fluid\" /></td>";
- }else{
- row += "<td><input type=\"text\" maxlength=\"128\" name=\"cantidades["+rw+"]["+col_i+"]\" id=\"edit-cantidades\" value=\"\" class=\"form-text fluid\" /></td>";
- }
- }
- row +="</tr>";
- $("#tabla-porciones").append(row);
- });
- $("#nueva_porcion").click(function(){
- //var r = $("td:gt(0)", $("#tabla-porciones")).length; alert("row" +r);
- //var c = $("tr:last td", $("#tabla-porciones")).length; alert("col" +c);
- $("#tabla-porciones tr:first").append("<th><input type=\"text\" maxlength=\"128\" name=\"porciones[]\" id=\"edit-porciones\" value=\"\" class=\"form-text fluid\" /></th>");
- var j = -1;
- $("#tabla-porciones tr:last td").each(function(c){
- col_p = c;
- });
- $('#tabla-porciones tr:not(:first)').each(function(){
- j += 1;
- $(this).append("<td><input type=\"text\" maxlength=\"128\" name=\"cantidades["+j+"]["+col_p+"]\" id=\"edit-cantidades\" value=\"\" class=\"form-text fluid\" /></td>");
- });
- });
- });
Add Comment
Please, Sign In to add comment