Pass string field to modal form bootstrap

0

Could you help me solve this problem that I have please?

What I'm trying to do is to pass the Client Name from the field $row['NomRazSoc'] of the file " listar.php ", to the modal form " clientes.php " passing as a parameter the string value of said field through the function " jsElimReg(name) ", so that I see that value in the tag span that has the identifier id="name-received" but it does not show it, and only shows numeric fields like $row['IdCliente']

Could someone tell me why it does not show string values?

File listar.php

<?php

$actionButton = '
<div class="btn-group">
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        Acción <span class="caret"></span>
    </button>
    <ul class="dropdown-menu">
        <li><a type="button" data-toggle="modal" data-target="#ModalModificar" onclick="jsModiReg('.$row['IdCliente'].')" style="cursor:pointer;"> <span class="glyphicon glyphicon-edit" style="color:purple"></span>&nbsp;Modificar</a></li>
        <li><a type="button" data-toggle="modal" data-target="#ModalEliminar" onclick="jsElimReg('.$row['NomRazSoc'].')" style="cursor:pointer;"> <span class="glyphicon glyphicon-trash" style="color:red"></span>&nbsp;Eliminar</a></li>      
    </ul>
</div>
';

?>

File clientes.js

function jsElimReg(name) {
$("#nombre-recibido").append(name);
}       

File clientes.php

<!-- INICIO DE FORMULARIO MODAL ELIMINAR REGISTRO -->
<div class="modal fade" tabindex="-1" role="dialog" id="ModalEliminar" style="margin-top:50px;">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header" style="height:48px;padding-top:8px;background-color:#347ab6;">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close" style="color:#ffffff;"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title"><i class="fa fa-trash" style="font-size:24px;color:#ffffff;"></i>&nbsp;<span style="color:#ffffff;">Eliminar Registro</span></h4>           
      </div>          
      <div class="modal-body">
        <p><center><span style="font-size:14px;font-weight:bold;color:#000000;">¿Está seguro de querer eliminar el registro selecionado?</span></center></p>
        <p><center><span style="font-size:14px;font-weight:bold;color:#000000;" id="nombre-recibido"> </span></center></p> 
      </div>              
      <div class="modal-footer" style="height:48px;padding-top:6px;background-color:#e6e6e6;">
        <button type="button" class="btn btn-danger btn-md" data-dismiss="modal"><i class="fa fa-times-circle" style="font-size:18px;color:white"></i>&nbsp;Cerrar</button>
        <button type="submit" class="btn btn-primary btn-md" tabindex="62"><i class="fa fa-floppy-o" style="font-size:18px;color:white"></i>&nbsp;Guardar</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- FIN DE FORMULARIO MODAL ELIMINAR REGISTRO -->
    
asked by Francisco Aguilar 21.09.2018 в 02:31
source

1 answer

0

In this part of your code:

 <li><a type="button" data-toggle="modal" data-target="#ModalEliminar"   onclick="jsElimReg('.$row['NomRazSoc'].')" style="cursor:pointer;"> <span  class="glyphicon glyphicon-trash" style="color:red"></span>&nbsp;Eliminar</a></li>     

to the jsElimReg method, your intention is to pass the name that is a string, but what happens is that you are passing the string without quotes, and in reality what remains is this: jsElimReg (Anzai) for example, add quotes so you receive it well:

    <li><a type="button" data-toggle="modal" data-target="#ModalEliminar"   onclick="jsElimReg(\''.$row['NomRazSoc'].'\')" style="cursor:pointer;"> <span  class="glyphicon glyphicon-trash" style="color:red"></span>&nbsp;Eliminar</a></li>   

and should finally look like jsElimReg ('Anzai') Try replacing the above in the string you use to display the HTML

    
answered by 21.09.2018 / 02:57
source