Skip to content

Instantly share code, notes, and snippets.

@antonioanerao
Created August 23, 2017 17:35
Show Gist options
  • Save antonioanerao/a04f3e5c06c6de86834124e24bdd4fd4 to your computer and use it in GitHub Desktop.
Save antonioanerao/a04f3e5c06c6de86834124e24bdd4fd4 to your computer and use it in GitHub Desktop.
<?php
require_once("autoload.php");
$crud = new Crud();
?>
<!DOCTY E html>
<html>
<head>
<title></title>
</head>
<body>
<?php
if(isset($_POST['cadastrar']))
{
$insert = $crud -> insert('users', 'nome = ?, cpf = ?', array($_POST['nome'], 'cpf'));
echo "ok";
}
?>
<form method="post" name="cadastrar" action="http://localhost/inputs/">
<button class="btn btn-success" href="javascript:void(0)"
id="addInput">
<span><i class="fa fa-plus-square" aria-hidden="true"></i> Adicionar</span>
</button>
<div id="dynamicDiv">
<div class="row">
<div class="col-lg-8">
<br><input class="form-control" name="nome[]" type="text">
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(function () {
var scntDiv = $('#dynamicDiv');
$(document).on('click', '#addInput', function () {
$(
'<div class="row">' +
'<div class="col-lg-8">' +
'<br>' +
'<input class="form-control" placeholder="" name="nome[]" type="text">' +
'</div>' +
'</div><br>').appendTo(scntDiv);
return false;
});
});
</script>
<br>
<input type="submit" name="cadastrar" value="Cadastrar">
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment