-4
I have a variable inside a code php with a while loop and need to modify this variable $codigo
inside the javascript.
This variable $codigo
receives a different number for each repeat loop
data-toggle='popover1', data-toggle='popover2' ...
And this value needs to be increased also to javascript
$('[data-toggle='popover1']'), $('[data-toggle='popover2']') ...
Follows the code:
$(document).ready(function(){
$('[data-toggle="popover<?php echo $codigo; ?>"]').popover({html: true});
});
<?php
$codigo = 1;
while ($codigo < 10) {
$codigo = $i;
$i++;
?>
<div class="container">
<button type="button" class="btn btn-primary" data-toggle='modal' data-target='#Alt'>MODAL</button>
</div>
<!-- Modal -->
<div class="modal fade" id="Alt" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<p><button id='id_codigo'
type="button" class="btn btn-primary"
data-position="top-left" title="Contato"
data-toggle="popover<?php echo $codigo; ?>"
data-placement="down" data-content="Nome: id='id_nome'
<br>Endereço: id='id_endereco'
<br>Contato: id='id_contato' ">Contato</button></p>
</div>
</div>
</div>
</div>
<?php
}
?>
Explains right which problem is facing, what you want to result and what outcome is currently happening.
– Leonardo Getulio
I’ll edit my question
– Carlos
In reality as this variable is inside a loop of repetition and receives an increment every repetition, also need this increment in javascript, IE, I need to always pass the value of the php variable to the java script inside this loop of repetition.
– Carlos
Can’t do what you want, manipulate with the Javascript variables hosted in PHP. There is a layer distinction between client(html) and server(php). It is a cycle the user requests a page. The server starts a code on php and when end all php activities the server returns to the client an html page and ceases its activity. The browser receives the page and renders it, depending on the actions of the user a new request is sent to the server. It is a.
– Augusto Vasques