2016-10-04 8 views
0

Ich versuche, Informationen aus der Schaltfläche in der Spalte "Aktionen" an das modale Div, ich rufe das modale mit JS, aber ich bin mir nicht sicher, wie Informationen aus der Tabelle zu senden das div. (Denken Sie daran, es hat verschiedene Informationen für jede Taste sein als jede Taste in einer anderen Zeile ist)Wie Informationen über jQuery übergeben werden

<?php 
error_reporting(0); 
    $con = new mysqli("localhost","****","****","****");  
if(mysqli_connect_errno()){   
echo(mysqli_connect_error());  
} 
$cuser = $_COOKIE['c_user']; 

$result = $con->query("SELECT * FROM calls");  
echo" 

<table class=\"table table-bordered responsive\"> 
     <thead> 
      <tr> 
       <th width=\"5%\">#</th> 
       <th>Call Status</th> 
       <th>Player ID</th> 
       <th>Player Name</th> 
       <th width=\"33%\">Actions</th> 
      </tr> 
     </thead> 
<tbody>";    
    while($row = $result->fetch_assoc()){ 
            echo "<tr> ";  
             echo("<td>" . $row['id'] . "</td> "); 
             echo("<td>" . $row['status'] . "</td> "); 
             echo("<td>" . $row['pid'] . "</td> "); 
             echo "<td>" . $row['pname'] . "</td> "; 
       echo "<td> "; 
            if($row['status'] == 'Pending'){ 
             echo "<a button type=\"button\" class=\"btn btn-warning\" href=\"calls.php?claim=true&callid=$row[id]\">Claim Call</button /a> "; 
            } else if($cuser == $row['claimedby']) { 
             echo "<a button type=\"button\" class=\"btn btn-danger\" href=\"calls.php?closecall=true&callid=$row[id]\">Close Call</button /a> "; 
            } else { 
                          echo "<a button type=\"button\" class=\"btn btn-warning disabled\">Claimed</button /a> "; 
            } 
            echo "<a button type=\"button\" href=\"javascript:;\" onclick=\"jQuery('#modal-2').modal('show');\" class=\"btn btn-info\">Call Info</button /a> "; 
            echo "<a button type=\"button\" id = $row[id] href=\"javascript:;\" onclick=\"jQuery('#modal-1').modal('show');\" class=\"btn btn-success\">Server Info</button /a> "; 
            echo "<a button type=\"button\" class=\"btn btn-primary\">Join Server</button /a> "; 
             echo "</td> "; 
} 
      echo "</tr> 
     </tbody> 
    </table>"; 

echo"<div class=\"modal fade\" id=\"modal-1\"> 
<div class=\"modal-dialog\" style=\"width: 50%\"> 
    <div class=\"modal-content\"> 

     <div class=\"modal-header\"> 
      <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button> 
      <h4 class=\"modal-title\">Call Info</h4> 
     </div> 

     <div class=\"modal-body\" id=\"serverHandle\"> 

     </div> 

     <div class=\"modal-footer\"> 
      <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">Close</button> 
     </div> 
    </div> 
</div> 
</div>"; 
    ?> 
+0

Sie Bootstrap-modale Verwenden? –

+0

@NorlihazmeyGhazali Ich habe das Modal in den Code, seine Gewohnheit. –

+0

@ICostaExDesigns: Möchten Sie Informationen von Buttons an Modal DIV senden, wenn jemand auf diese Schaltflächen klickt? – mi6crazyheart

Antwort

0

Haben Sie irgendeine Art von Informationen von Buttons zu Modal DIV senden möchten, wenn jemand auf diese Schaltflächen klickt? Wenn Sie das möchten, können Sie Ihrer Schaltfläche ein benutzerdefiniertes Attribut wie diese <button info='my-info' id=''>Click</button> hinzufügen. Wenn dann jemand auf diese Schaltfläche klickt, können Sie den Wert dieses Attributs mit JavaScript this & mithilfe einer ID aus Modal DIV in das MODAL-Fenster kopieren .

0

Sie können diese Schaltfläche zusammen mit einem Klickereignis hinzufügen.

 data-value="<?php echo $Something->SomeValue;?>" 

Dann, wenn das Click-Ereignis ausgelöst wird, können Sie den Wert wie folgt erhalten:

$(this).data("value"); 

Sie verschiedenen Daten- [tag] können mehr Informationen zu übergeben.

Oder als Alternative, fügen Sie diese zu jeder Taste:

onclick='someFunction("<?php echo $Something->SomeValue;?>")'; 
Verwandte Themen