Last active
August 27, 2015 14:36
-
-
Save mbarrerar/719e9473ffba32b29653 to your computer and use it in GitHub Desktop.
test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="es"> | |
<head> | |
<title>Dinamicos</title> | |
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet"> | |
<link href="http://cdnjs.cloudflare.com/ajax/libs/jQuery-Validation-Engine/2.6.4/validationEngine.jquery.css" rel="stylesheet"> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/jQuery-Validation-Engine/2.6.4/jquery.validationEngine.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/jQuery-Validation-Engine/2.6.4/languages/jquery.validationEngine-es.js"></script> | |
<style> | |
.top-buffer { | |
margin-top:20px; | |
} | |
</style> | |
</head> | |
<body> | |
</head> | |
<body> | |
<div id="container "> | |
<div class="row-fluid top-buffer"> | |
<div class="col-lg-6 col-lg-offset-3 text-center"> | |
<form id="miform" action="guardar.php" method="post" name="miform" > | |
<table id="tblprod" class="table table-hover table-bordered"> | |
<thead> | |
<tr> | |
<th>Codigo Producto</th> | |
<th>Nombre</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<td>1</td> | |
<td> | |
<div class="form-group col-lg-12"> | |
<div class="form-group col-xs-5"> | |
<input class="form-control validate[required]" id="codigo" name="prod[0][codigo]" /> | |
</div> | |
<div class="form-group col-xs-5"> | |
<input class="form-control validate[required]" id="cantidad" name="prod[0][cantidad]" /> | |
</div> | |
</div> | |
</td> | |
</tr> | |
</tbody> | |
</table> | |
<button id="btnsubmit" type="submit" class="btn btn-success">Guardar</button> | |
</form> | |
</div> | |
</div> | |
</div> | |
<script type="text/javascript"> | |
$(function() { | |
var count = 0; | |
var countEnter = 0; | |
jQuery("#miform").validationEngine({promptPosition : "centerRight:0,-5"}); | |
$("#codigo").focus(); | |
$(document).on("keypress", "form", function(event) { | |
return event.keyCode != 13; | |
}); | |
$(document).on("keyup", "input", function(e) { | |
if(e.keyCode == 13) | |
{ | |
count++; | |
countEnter++; | |
var inputs = $(this).closest('form').find(':input'); | |
inputs.eq(inputs.index(this) + 1).focus(); | |
if(countEnter == 2){ | |
$('#tblprod tr:last').after('<tr><td>'+count+'</td><td><div class="form-group col-lg-12"><div class="form-group col-xs-5"><input class="form-control validate[required]" name="prod['+count+'][codigo]" /></div> <div class="form-group col-xs-5"><input class="form-control validate[required]" name="prod['+count+'][cantidad]" /></div></div></td></tr>'); | |
var inputs = $(this).closest('form').find(':input'); | |
inputs.eq(inputs.index(this) + 1).focus(); | |
countEnter = 0; | |
} | |
event.preventDefault(); | |
} | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment