0
I have a modal that opens the customer data and I have clients Cpf and cnpj, I would like to show the data according to the value of the variable $razao_social, if this variable contains some data, then the modal shows the content of the client that has a cnpj, otherwise shows the data of the client that is Cpf, because, a client that does not have data cnpj is a client that has Cpf and vice versa.
As it is a modal and it opens in a list with several clients I need to do this treatment with javascript, however, I have no affinity with language.
I did the way I know with php, and soon this way the modification is present for all who appear in the list and is not the right, I want each modal have its own individual search filtering whether it is cnpj or Cpf, IE, I have to employ javascript.
Follow the example in php:
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!--Alinhamento de Campos-->
<input id="id_cadastro" type="hidden" class="form-contratol" name="id_cadastro">
<!--Primeira Coluna-->
<div class='row' align = left>
<!--Alinhamento de Campos Primeira Coluna-->
<div class='col-sm-6'>
<?php
$razao_social = "TESTE LTDA";
if ($razao_social != ''){
echo "<!--Campo Razão Social-->
<label for='razao_social' class='control-label' >
<br>Razão Social:<br></label>
<div class='input-group'>
<div class='input-group-addon'>
<span class='glyphicon glyphicon-user' id='basic-addon-razao_social'></span>
</div>
<input type='text' name='razao_social' id='id_razao_social' class='form-control' required autofocus placeholder='Ex.: José Emanoel'><br>
</div>
<!--Fim Campo Razão Social-->
<!--Campo NOME_FANTASIA-->
<label for='razao_social' class='control-label' >
<br>Nome Fantasia:<br></label>
<div class='input-group'>
<div class='input-group-addon'>
<span class='glyphicon glyphicon-user' id='basic-addon-razao_social'></span>
</div>
<input type='text' name='razao_social' id='id_razao_social' class='form-control' required autofocus placeholder='Ex.: José Emanoel' onkeyup='limite_nome_fantasia(this)'><br>
<script>
function limite_cliente(obj) {
obj.value = obj.value.substring(0,70);
}
</script>
</div>
<!--Fim Campo NOME_FANTASIA-->
<!--Campo CNPJ-->
<label for='cnpj' class='control-label' >
<br>CNPJ:<br></label>
<div class='input-group col-lg-8'>
<div class='input-group-addon'>
<span class='glyphicon glyphicon-info-sign' id='basic-addon-cnpj'></span>
</div>
<input type='text' name='cnpj' id='id_cnpj' class='form-control cnpj' maxlength='30' required autofocus placeholder='Apenas Números'><br>
</div>
<!--Fim Campo CNPJ-->
</div>
</div>
</form>";
}else{
echo "<!--Campo CPF-->
<label for='cpf' class='control-label' >
<br>CPF:<br></label>
<div class='input-group'>
<div class='input-group-addon'>
<span class='glyphicon glyphicon-user' id='basic-addon-cpf'></span>
</div>
<input type='text' name='cpf' id='id_cpf' class='form-control' required autofocus placeholder='Ex.: José Emanoel'><br>
</div>
<!--Fim Campo CPF-->
<!--Campo NOME-->
<label for='nome' class='control-label' >
<br>Nome:<br></label>
<div class='input-group'>
<div class='input-group-addon'>
<span class='glyphicon glyphicon-user' id='basic-addon-nome'></span>
</div>
<input type='text' name='nome' id='id_nome' class='form-control' required autofocus placeholder='Ex.: José Emanoel'><br>
</div>
<!--Fim Campo NOME-->
</div>
</div>
</form>";
?>
more detail that there friend.
– Victor OCV
I’ll edit the question to clarify.
– Carlos