0
I would like to know how to implement a modal to receive the change data.
I am using the W3.
In Image Below when the user presses the ABSENT button has to open a MODAL
with the information of the patient of the line. Name, tel, his health insurance, card number etc.
Theoretically I have to make a php request to popular modal, but the problem is that I don’t know where to put this request or if the way I’m calling the modal for this case is wrong
Below I show how I call ANOTHER MODAL when I press the button SNAP
HTML
<td> <input type="button" class="add"
onClick="chama_consulta_01_modal('',
'{$row['id_m_h']}','{$diaN}',
'atendimento')"
value="ENCAIXE"></td>
JAVASCRIPT
function chama_consulta_01_modal(id_linha_tabs,id_m_h, dia,veio_de)
{
document.getElementById('id_consulta_01_modal').style.display='block';
document.getElementById('id_veio_de').innerHTML = veio_de;
document.getElementById("id_m_h_div").innerHTML = id_m_h;
document.getElementById("data_div").innerHTML =
document.getElementById("id_data_atual").innerHTML;
document.getElementById("index_tab_div").innerHTML = dia;
};
The code above shows this MODAL
The code I use to produce MODAIS is like this:
<div class="w3-container">
<div id="id_consulta_atendimento_02_modal" class="w3-modal" style="padding-top:200px">
<div class="w3-modal-content">
<center>
<header class="w3-container w3-teal">
<span onclick="document.getElementById('id_consulta_atendimento_02_modal').style.display = 'none'"
class="w3-button w3-display-topright">×
</span>
<h2>STATUS PACIENTE</h2>
</header>
</center>
<div class="w3-container">
<div class="row"><br>
<div class="col-md-1"></div>
<div class="col-md-10" style="text-align: center">
<div class="form-group">
<b><font color="blue" size="3"><label id="id_ca02m_nome_paciente"><></font><b>
</div>
</div>
</div><br>
<fieldset>
<legend>CONVÊNIO...:</legend>
<div class="row">
<div class="col-md-4">
<select name="cb_convenio" class="form-control" id="id_cb_convenio" autofocus style="width:90%;" required="true">
<option value="0" disabled selected hidden>
SELECIONE
</option>
<?php include 'consulta_atendimento_02_modal_cb_convenio.php'?>
</select>
</div>
</div><br>
</fieldset>
<br>
<div class="row" align="center">
<div class="col-md-12">
<button onclick="document.getElementById('id_consulta_atendimento_02_modal').style.display = 'none'" type="button" class="w3-button w3-red">FECHAR</button>
</div>
</div>
</div>
<br>
<footer class="w3-container w3-teal">
<p>Modal Footer</p>
</footer>
</div>
</div>
</div>
The code above is a prototype for the MODAL in question that I’m looking to do.
This code is in a file .php. It is on the page of MARKED QUERIES:
<html CONSULTAS MARCADAS>
<body>
CÓDIGO..CÓDIGO..
CÓDIGO..CÓDIGO..CÓDIGO..
<?php include 'selecionar_paciente_modal.php' ?>
<?php include 'status_paciente_modal.php' ?>
<script>
CÓDIGO..CÓDIGO..
</script>
</body>
</html>
When I put php code in the status_paciente_modal.php to connect and assemble the MODAL with the patient data, this code does not work properly because when the MARKED QUERIES page enters, the include status_paciente_modal.php code is triggered and the error on the page.
One way I found was to put attributes in the boot:
<td>
<input type='button' class='add A'
data-paciente_nome="<?php echo ($row['nome']);?>"
data-paciente_cpf="<?php echo ($row['cpf']);?>"
data-id_convenio="<?php echo($row['id_convenio_fk']); ?>"
id_consulta_ca_01_busca ="<?php echo($row['tem_consulta']);?>"
onclick= status_paciente(self)
value='AUSENTE'>
</td>
Ai in the patient status function caught these attributes:
function status_paciente(botao)
{
document.getElementById('id_consulta_atendimento_02_modal').style.display='block';
document.getElementById("id_ca02m_paciente_nome").innerHTML =
botao.getAttribute('data-paciente_nome');
document.getElementById("id_ca02m_paciente_cpf").innerHTML =
botao.getAttribute('data-paciente_cpf');
document.getElementById("id_cb_convenio_02_modal").value =
botao.getAttribute('data-id_convenio');
}
Running the above code works. Ai a friend of mine programmer always says..:
"GOOD CODE IS THE ONE THAT WORKS"
I know that when we are being bullied by TIME/ CHIEF it is very true. :)
But right now it’s NOT the case :).
Then I return to the original question of the POST.. How/Where should I implement php code
to make a consultation at the base is popular the MODAL?
Because as I said before despite knowing how to make php queries and call them in various places and in various ways, in this particular situation I did not succeed. Certainly for my lack of language experience :)
I hope I’ve made my need clear.
If someone understands and succeeds to synthesize it would be cool :) and I would appreciate :).
If someone "THINK" who understood my need please.. do not change anything.. write to me and I will try to explain otherwise :)
Hug to all :)
If you’re willing to use
JQuery
, recommendajax()
– I_like_trains
Good morning @I_like_trains . Thanks for the tip :). Would you have an example of what you’re talking about.. or something to read?? Hugs
– Ricardo M.Souza
Here is the documentation of
ajax
, I will give an example soon http://api.jquery.com/jquery.ajax/– I_like_trains