简体   繁体   English

使用带有GET方法的php和javascript定位iframe

[英]Targeting an Iframe using javascript with php inside with GET method

Im a complete newbie in being a php developer so please forgive me if im too dumb xD 我是一名完全的新手,成为php开发人员,所以如果我太笨了xD,请原谅我

Im have a link that will need to send a specific value for a variable using onclick, but the thing is, i used the get method for this but i cant bring the button to load it to the other iframe which is also inside the webpage. 我有一个链接,该链接需要使用onclick发送变量的特定值,但事实是,我为此使用了get方法,但无法将按钮加载到也位于网页内的其他iframe中。

heres the code of the first iframe with the link 带有链接的第一个iframe的代码

   <?php 
<button name="link" type="button" class="search-button" id='.$propid.' onClick="reply_click(this.id)">Read More!</button>
             <script type="text/javascript">
                function reply_click(clicked_id)
                {
                     var javascriptVariable = clicked_id;
                    window.location.href = "propdetails.php?propid=" + javascriptVariable;


            }
            </script> ?>

and heres the other iframe with the name of "propdet" 这是另一个名为“ propdet”的iframe

<?php
    $propid=$_GET['propid']; 
echo '
    $propid<br>
<hr size="5">';
?>

Notes: "the two codes are in 2 different iframes on the same page." 注意:“这两个代码位于同一页面的2个不同的iframe中。” Problem: "The first code loads on the same iframe where i clicked the link." 问题:“第一个代码在我单击链接的同一iframe上加载。” Goal: "I need to load on the iframe named ="propdet" without reloading the contents of the other iframe". 目标:“我需要在名为=“ propdet”的iframe上加载,而无需重新加载其他iframe的内容”。

Try This, 尝试这个,

<?php 
<button name="link" type="button" class="search-button" id="$propid" onClick="reply_click(this.id)">Read More!</button>
         <script type="text/javascript">
            function reply_click(clicked_id)
            {
                 var javascriptVariable = clicked_id;
                window.location.href = "propdetails.php?propid=" + javascriptVariable;


        }
        </script> ?>

and

<?php
$propid=$_GET['propid']; 
echo "
$propid<br>
<hr size=\"5\">";
?>

One thing to remember is that there is no interpolation of the variables with their values if they are enclosed in single quotes. 要记住的一件事是,如果变量用单引号引起来,则不会对其值进行插值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM