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

问题描述 投票:1回答:1

我试图在模型框中打开从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 =“details.php?view_id =”而不是#openModel?

我是新学员,请帮忙。

php html mysql
1个回答
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>
© www.soinside.com 2019 - 2024. All rights reserved.