Load data from a field after pressing a button

0

I need to load data from a field in a table.

Example: Table (Template), the person is filling out the form and wants to use this template in the Text field, and with that it would click on a button (Load Template) and load this template into the Text input.     

asked by anonymous 05.06.2014 / 14:28

1 answer

2

You can solve this with ajax, if you have already done the so famous fields select "State X Municipality", follow the same reasoning.

Clicking the button will trigger an event that will have an ajax that will point to a php file, where you will get the parameter and with it will mount the specific query and return the database data.

// cadastrarPaciente.js
$("#uf").on("change", function(){
    $.get("modulos/pacientes/ajax_listarCidade.php",
        {uf: $("#uf").val()},
            function(dados){
            $("#cod_cidade").empty();
            $("#cod_cidade").append(dados);
    });
});
// ajax_listarCidade.php
$PArray['uf'] = $_REQUEST['uf'];

$sql = "SELECT cod_mun, nome_mun FROM TMunicipio WHERE uf = '{$PArray['uf']}'";
...

Just follow this reasoning.

    
05.06.2014 / 14:59