1
Good morning I need to update the data on my index
They are loaded as follows
Javascript
$("document").ready(function () {
function gerarFunctionario(obj) {
return '<div class="col-md-4 col-sm-4 col-xs-12 profile_details">' +
'<div class="well profile_view">' +
'<div class="col-sm-12">' +
'<h4 class="brief"><i>' + obj.nomeCargo + '</i></h4>' +
'<div class="left col-xs-7">' +
'<h2 id="NumeFunc">' + obj.nomeFunc + '</h2>' +
'<p><strong>Cargo: </strong>' + obj.nomeCargo + ' </p>' +
'<ul class="list-unstyled">' +
'<li><i class="fa fa-building"></i> Address: </li>' +
'<li><i class="fa fa-phone"></i> Phone #: </li>' +
'</ul>' +
'</div>' +
'<div class="right col-xs-5 text-center">' +
'<img src="../images/user.png" alt="" class="img-circle img-responsive">' +
'</div>' +
'</div>' +
'<div class="col-xs-12 bottom text-center">' +
'<div class="col-xs-12 col-sm-6 emphasis">' +
'</div>' +
'<div class="col-xs-12 col-sm-6 emphasis">' +
'<button type="button" class="btn btn-success btn-xs"> <i class="fa fa-user">' +
'</i> <i class="fa fa-comments-o"></i> </button>' +
'<button id="atualizar" type="submit" class="btn btn-primary btn-xs">' +
'<i class="fa fa-user"> </i> atualizar' +
'</button>' +
'</div>' +
'</div>' +
'</div>' +
'</div>';
}
var data2 = [];
$.getJSON('../include/carrFunc.php', function (j) {
var itens = [];
for (var i = 0; i < j.length; i++) {
data2 [i] = {"idFuncionario": j[i].idFuncionario, "nomeFunc": j[i].nomeFunc, "nomeCargo": j[i].nomeCargo}
}
var html = data2.map(gerarFunctionario).join('');
$("#inicio").html(html);
$('.carregando').hide();
console.log(data2);
});
});
HTML
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12 text-center">
</div>
<div class="clearfix"></div>
<div id="inicio" >
</div><!-- fim da div principal-->
</div>
PHP
<?php
include "conexao.php";
$sql = "SELECT f.idFuncionario,f.nomeFunc,f.endFunc,c.nomeCargo FROM
tbfuncionario f , tbCargo c WHERE f.fkCargo=c.idCargo ;";
$result = $conn->query($sql);
$data = array();
if ($result->num_rows > 0) {
// output data of each row
$data = $result->fetch_all( MYSQLI_ASSOC );
//print_r ($data);
} else {
echo "Nenhum resultado encontrado.";
}
$conn->close();
//echo "<br>";
echo json_encode( $data );
?>
I need that when pressing the button update the data I uploaded to go to another register forumalario to do the updade
Registration HTML
<form id="formCad" class="form-horizontal form-label-left" novalidate>
<fieldset>
<span class="section">Dados do Funcionario</span>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Nome e Sobrenome: <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="txtnome" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="name" placeholder="digite seu nome" required="required" type="text">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-4" for="cpf">CPF: <span class="required">*</span>
</label>
<div class="col-xs-6">
<input id="txtcpf" type="text" onkeypress="return Onlynumbers(event)" maxlength=11 required="required" class="form-control col-md-7 col-xs-4">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-4" for="endereco">Endereço:<span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="txtendereco" type="text" data-validate-words="2" name="endereco" required="required" placeholder="digite seu endereço" class="form-control col-md-7 col-xs-4">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-4" for="cep">CEP: <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-10">
<input id="txtcep" type="text" onkeypress="return Onlynumbers(event)" name="cep" maxlength="8" required="required" placeholder="digite o CEP" class="form-control col-md-7 col-xs-4">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-4" for="complemento">Complemento:
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="txtcomplemento" type="complemento" name="complemento" placeholder="digite o complemento" class="form-control col-md-7 col-xs-4">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-4" for="bairro">Bairro: <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="txtbairro" type="text" name="bairro" required="required" placeholder="digite o bairro" class="form-control col-md-7 col-xs-4">
</div>
</div>
<div class="item form-group">
<label id="estado" class="control-label col-md-3 col-sm-3 col-xs-12" for="textarea">Estado <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-6">
<select id="carrEst" >
</select>
</div>
</div>
<div class="item form-group">
<label id="cidade" class="control-label col-md-3 col-sm-3 col-xs-12" for="textarea">Cidade <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-6">
<select name="carrCid" id="carrCid">
<option value="">-- Escolha um estado --</option>
</select>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-4" for="dtaNascimento">Data de Nascimento:<span class="required">*</span>
</label>
<div class="col-md-6">
<input id="dtaNascimento" type="date" name="dtaNascimento" required="required" class="col-xs">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-4" for="Sexo:">Sexo:<span class="required">*</span>
</label>
<select id="cmbSexo">
<option value="Masculino">Masculino</option>
<option value="Feminino">Feminino</option>
</select>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="email">Email: <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="txtemail" type="email" name="email" required="required" placeholder="digite seu email" class="form-control col-md-7 col-xs-12">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-4" for="dtaAdmissao">Data de Admissão:<span class="required">*</span>
</label>
<div class="col-md-6">
<input id="dtaAdmissao" type="date" name="dtaAdmissao" required="required" class="col-xs">
</div>
</div>
<!-------------------------------------------------------- Area reservada para foreign keys -------------------------------->
<div class="row">
<div class="item form-group">
<label id="departamento" class="control-label col-md-3 col-sm-3 col-xs-12" for="textarea">Departamento <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-2 col-xs-12">
<select id="carrDpto" >
</select>
</div>
</div>
<div class="item form-group">
<label id="cargo" class="control-label col-md-3 col-sm-3 col-xs-12" for="textarea">Cargo: <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-2 col-xs-12">
<select id="carrCarg" name= "carrCid" >
<option value="">-- Escolha um Cargo --</option>
</select>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="salario">Salario: <span class="required">*</span>
</label>
<div class="col-xs-4">
<input id="txtsalario" type="text" name="salario" onkeypress="return Onlynumbers(event)" required="required" class="form-control col-md-7">
</div>
</div>
<div class="item form-group">
<label id="status" class="control-label col-md-3 col-sm-3 col-xs-12" for="textarea">Status: <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-2 col-xs-12">
<select id="carrStatus" >
</select>
</div>
</div>
</div>
<!-------------------------------------------------------------------------------------------------------->
<div class="ln_solid"></div>
<div class="form-group">
<div class="col-md-6 col-md-offset-3">
<button type="submit" class="btn btn-primary">Cancelar</button>
<button id="btngravar" type="submit" class="btn btn-success">Cadastrar</button>
</div>
</div>
</fieldset>
</form>
Your intention is to click the refresh button, take the user to a different page from your index or on that same page display that form somewhere?
– Pedro Souza
@Pedrosouza My intention is to open in another page.. I already have it ready
– Somdesp