2017-02-01 7 views
0

私は現在ボタンで開くモーダルを持っており、変数を渡して自分のデータベースから動的データを取り込む方法がわからないようです。私はモーダルに送信する必要があるURLにいくつかの変数があります。モーダルウィンドウへのリンクで変数を渡す

本当に必要なのは、モーダルを開くボタンをhrefリンクに置き換えることです。

Modal 
 
<!---BUTTON THAT OPENS MODAL---> 
 

 
<button onclick="document.getElementById('id01').style.display='block'" style="width:auto;">Login</button> 
 

 
<!---END BUTTON---> 
 

 
<!---MODAL---> 
 
    <div id="id01" class="modal"> 
 
    <form class="modal-content animate" action="action_page.php"> 
 
    <div class="container"> 
 

 
\t <div class="container" style="background-color:#f1f1f1"> 
 
    <button type="button" onclick="document.getElementById('id01') 
 
    .style.display='none'" class="cancelbtn">Cancel</button> 
 
     <span class="psw">Forgot <a href="#">password?</a></span> 
 
     </div> 
 
     </form> 
 
     </div> 
 

 
<!---END MODAL---> 
 

 
This is what I need to open the modal with (or similar) and pass the variables to it. 
 

 
    <a href="#CGI.SCRIPT_NAME#?viewas=#dtDay#&id=#qEventSub.id#" title="#DateFormat(dtDay, "mmmm d, yyyy")#" style="color: white;"onclick="document.getElementById('id01').style.display='block'" style="width:auto;>#Day(dtDay)#</a>

+0

_sentがmodal_に何を意味するのですか?どのように/どこでそれらを使用するのですか? –

答えて

0

私はこれを知っています!私はこの問題:)

<button type="button" class="btn btn-info btn-sm" data-toggle="modal" data-target="#Comments-<?php echo $job_numb;?>">Comments</button> 
 

 
<!-- Modal --> 
 
<div id="Comments-<?php echo $job_numb;?>" class="modal fade" 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">Comments for <?php echo html_entity_decode($job_name) . "&nbsp;|&nbsp;" . $job_numb;?></h4> 
 
     </div> 
 
     <div class="modal-body"> 
 
     <p><?php echo html_entity_decode(nl2br($comments));?></p> 
 
     </div> 
 
     <div class="modal-footer"> 
 
     <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
 
     </div> 
 
    </div> 
 

 
    </div> 
 
</div>

参照を持っていた、私がやったことは、レコードごとにSQLによって生成されたの$ job_numbを、呼び出し、モーダルに至ることを渡しました。ループは各モーダルに対して固有のIDを作成します。

+0

HA HA私はそれがJavascriptであることを認識しています。しかし、同じ原則がここにあります。変数に 'id'を追加するだけです。 – scoopzilla

関連する問題