我如何使用锚标记href打开我的代码的详细数据?

时间:2017-10-04 16:00:17

标签: php html mysql

我试图在模型框中打开从php-mysql获取的详细数据,而不是新的html页面。目前它正在其他html页面中打开,但我想在模型框中添加它。

这是我目前的代码:

<a class="btn btn-info"  href="details.php?view_id=<?php echo $row['userID']; ?>" title="click for Details" onclick="details.php"><span class="glyphicon glyphicon-eye-open"></span> Show Details</a> 

这里指的是details.php?view_id,但是找到了像id选择器一样的模型示例,

<a href="#openModal">Show Details</a>
  <div id="openModal" class="modalDialog">
               <a href="#close" title="Close" class="close">X</a>
                <div>
                    <a href="#close" title="Close" class="close">X</a>
                    <h2>Modal Box</h2>

                </div>
            </div> 

如何添加 href =&#34; details.php?view_id =&#34; 而不是 #openModel ??

我是新学员,请帮忙。

1 个答案:

答案 0 :(得分:0)

function edit_m_id(str){
  var xhttp;
    document.getElementById("edit_con_tent").innerHTML = "<center>loading.......</center>";
  xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("edit_con_tent").innerHTML = this.responseText;
    }
  };
  xhttp.open("GET", "edit_m_con.php?q="+str, true);
  xhttp.send();   
}
<a href="#small-modal" onclick="edit_m_id('<?php echo $id_rand;?>')" data-toggle="modal">Edit</a>

<div id="small-modal" class="modal fade" role="dialog">
  <div class="modal-dialog">

   
    <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">
       <span id='edit_con_tent'></span>
        <p>Some text in the modal.</p>
      </div>
      <div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div>

相关问题