简体   繁体   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> 

hi, here i want to pass unique php variable via href/anything else into for i frame src to pass.after see numbers of tutorials i get the value of $nid in $(item).attr("id"); 嗨,在这里,我想通过href /其他方式将唯一的php变量传递给我,以便传递给我frame src。 but how to pass this value to i try u can see in my code..but its not working plz help 但是如何将这个值传递给我尝试你可以在我的代码中看到..但是它不起作用请帮助

If js is in separate file (.js), then it's not parsed by PHP and therefore PHP tags won't work there. 如果js位于单独的文件(.js)中,则PHP不会对其进行解析,因此PHP标记将无法在其中运行。

In this case You could solve this by 2 scenarios: 在这种情况下,您可以通过两种方案解决此问题:

1) Move function declaration to file that is parsed by PHP (like second block of Your code, where this function is called) 1)将函数声明移到PHP解析的文件中(例如,调用此函数的代码的第二个块)

2) Add input parameter to "confirmno" function. 2)将输入参数添加到“ confirmno”功能。 Parameter sets "nid" value and it is given by PHP file (instead of 'onclick="confirmno()' You would use 'onclick="confirmno()'. 参数设置“ nid”值,它由PHP文件提供(而不是“ onclick =“ confirmno()”,而应使用“ onclick =” confirmno()”)。

Code: 码:

<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