Necesito pasar de PHP
un JSON
a cada campo que le corresponda el valor, por el momento pruebo con el valor del select
y se supones que debería ponerlo en el campo cédula. Adjunto el código
$(document).ready(function(){
$.post("../php/llenar.php", function(data){
$("#capitan").html(data);
});
$("#capitan").change(function(){
alert($("#capitan").val());
$.get("../php/modificar.php",{cedula: $("#capitan").val()},function(data){
$("#cedula").val(data.cedula);
},"json");
});
});
<!DOCTYPE html>
<html lang = "es">
<head>
<meta charset = "UTF-8">
<title id="usuario"></title>
<link rel="stylesheet" href="../css/reg.css">
<script src = "../js/jquery-3.2.1.min.js"></script>
<script src = "../js/modificar_Cap.js"></script>
</head>
<body>
<form method= "post" class = "form-registro">
<h2> Modificar capitanes</h2>
<div class ="contenedor-input">
<select name = "capitan" id = "capitan" class = "input-100">
</select>
<input type = "text" id = "cedula" name = "cedula" placeholder = "Cedula" class = "input-100" disabled = false/>
<input type = "text" id = "nombre" name = "nombre" placeholder = "Nombres" class = "input-48" disabled = false/>
<input type = "text" id = "apellido" name = "apellido" placeholder = "Apellidos" class = "input-48" disabled = false/>
<input type = "email" id = "mail" name = "mail" placeholder = "Correo electronico" class = "input-100" disabled = false/>
<input type = "text" id = "user" name = "user" placeholder = "Usuario" class = "input-48" disabled = false/>
<input type = "text" id = "pwd" name = "pwd" placeholder = "Contraseña" class = "input-48" disabled = false/>
<input type = "text" id = "privilegio" name = "privilegio" placeholder = "Cedula" class = "input-100" disabled = false/>
<input type = "button" value = " Modificar capitan" class = "btn-enviar" id = "btn-enviar" disabled = false/>
</div>
</form>
</body>
</html>
PHP
<?php
$cedula = $_GET['cedula'];
echo $cedula;
echo json_encode(array("cedula"=>$cedula));
?>