2016-05-04 5 views
0

私は、ユーザーがクリックしたとき、モーダルは、以下を含む表示されるというリンクがありますidを持つリンクからmodalを開くには?

<?php 

    include ('dbcontroller.php'); 
    if(isset($_GET['view_id'])) 
    { 
     $id=$_GET['view_id']; 
     $sql = mysqli_query($conn, "SELECT * from press where id='$id'"); 
     $row = mysqli_fetch_array($sql); 
    ?> 

    <input type="hidden" value="<?php echo $row['id']; ?>" /> 
    <?php echo $row['reason']; ?> 

     <a href="index.php" class="btn btn-primary">GO BACK</a> 
    <?php 
    } 
    $conn->close(); 
?> 

上記のコードは、私は、ユーザーがリンクをクリックしたとき、それはそれに彼をリダイレクトするように何をしたかでありますページ。しかし、私はそれが多くの内容ではないので、代わりにモーダルダイアログにしたい。

これは、ユーザーがクリックするリンクです。このリンクをどのようにしてモーダルダイアログに開きますか?

<a href="viewReason.php?view_id=<?php echo $row['id'];?>">Click to view </a> 

私はこのサイトと他のサイトでいくつか見ましたが、それらはすべて、モーダルダイアログを表示するためのIDのないリンクです。私は私と同じ問題を見つけられなかったので、私は助けを求めることにしました。

答えて

0

にあなたは私が行の値を取得する方法上の問題を抱えていないよ行の値

<!DOCTYPE html> 
     <html lang="en"> 
     <head> 

      <meta charset="utf-8"> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> 
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> 
      <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> 
     </head> 
     <body> 

     <div class="container"> 

      <!-- Trigger the modal with a button --> 

     <br><br><br><br> 
     <table id="prab" border="1"> 
      <tr> 
      <td>Jill</td> 
      <td>Smith</td> 
      <td>50</td> 
      <td><button type="submit" class="btn btn-default" data-toggle="modal" data-target="#myModal" value="Jackson"><span class="glyphicon glyphicon-envelope"></span>Invite</button></td> 
      </tr> 
      <tr> 
      <td>Eve</td> 
      <td>Jackson</td> 
      <td>50</td> 
       <td><button type="submit" class="btn btn-default" data-toggle="modal" data-target="#myModal" value="smith" ><span class="glyphicon glyphicon-envelope"></span>Invite</button></td> 
      </tr> 
     </table> 
      <!-- Modal --> 
      <div class="modal fade" id="myModal" role="dialog"> 
      <div class="modal-dialog"> 

       <!-- Modal content--> 
       <div class="modal-content"> 
       <div class="modal-header"> 
        <button type="button" class="close" data-dismiss="modal">&times;</button> 
        <h4 class="modal-title">Modal Header</h4> 
       </div> 
       <div class="modal-body"> 
        <p>clicked value </p> 

        <input type="text" id="valueof" > 


       </div> 
       <div class="modal-footer"> 
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
       </div> 
       </div> 


      </div> 
      </div> 

     </div> 
     <script type="text/javascript"> 
      $('#prab').click(function(e){ 
       // alert($(e.target).val()); 
      document.getElementById("valueof").value = $(e.target).val(); 

     }) 
      </script> 


     </body> 
     </html> 
+0

を取得するには、次のコードを使用することができますねえ、私の問題は、にして、IDとのリンクを表示する方法でありますモーダルダイアログ。 – Felix

関連する問題