簡體   English   中英

如何使用href將php變量值傳遞給div的iframe

[英]How to pass php variable value to div's iframe using href

 <?php $query="SELECT * FROM `notification` where `Status`='1' && `ownerid`='$userid' "; $result = mysql_query($query); $count=0; while($row=mysql_fetch_array($result)) { $nid=$row['notifid']; $pr="select * from `Swap` where `notifid`='$nid'"; $prm=mysql_query($pr); $prow=mysql_fetch_assoc($prm); $rid=$prow['Requesterid']; $query1="select * from `myuser` where `Userid`='$rid'"; //echo $query1; $result1=mysql_query($query1); $row1=mysql_fetch_assoc($result1); $rname=$row1['Firstname']; //echo $rname; ?> <div style="width:100%; background: rgb(228, 228, 228);margin: 20px;padding: 20px;"> <h1>A New Swapping Request from <?php echo $rname; ?></h1> Your sweater is choose for swapping.....you want to give permission?? <div onclick="clicked(this);" id="<?php echo $nid; ?>">VIEW REQUEST</div> </div> <?php $count++; } ?> <div id="light" class="white_content" style=" height: auto;"> <a href = "javascript:void(0)" style="background: #EAEAEA; padding: 5px 7px; color: #000; float: right;" onclick="confirmno()">X</a> <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script> <script type="text/javascript"> function clicked(item) { document.getElementById('light').style.display='block'; document.getElementById('fade').style.display='block'; var a = $(item).attr("id"); } </script> <div id="stylized" class="myform"> <iframe width="100%" height="400px" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="confirmed.php?x="+a> </iframe> </div> </div> 

嗨,在這里,我想通過href /其他方式將唯一的php變量傳遞給我,以便傳遞給我frame src。 但是如何將這個值傳遞給我嘗試你可以在我的代碼中看到..但是它不起作用請幫助

如果js位於單獨的文件(.js)中,則PHP不會對其進行解析,因此PHP標記將無法在其中運行。

在這種情況下,您可以通過兩種方案解決此問題:

1)將函數聲明移到PHP解析的文件中(例如,調用此函數的代碼的第二個塊)

2)將輸入參數添加到“ confirmno”功能。 參數設置“ nid”值,它由PHP文件提供(而不是“ onclick =“ confirmno()”,而應使用“ onclick =” confirmno()”)。

碼:

<script type="text/javascript">
    function confirmno(nid) {
    var con=confirm('You want keep this?');
    if (con == true) {
      window.location="notification.php";
    } else {
      window.location="confirmed1.php?nid=" + nid;
    }
}
</script>

<a href = "javascript:void(0)" style="background: #EAEAEA; padding: 5px 7px; color: #000; float: right;" onclick="confirmno(<?php echo $nid; ?>)">X</a>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM