Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Im a complete newbie in being a php developer so please forgive me if im too dumb 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.

heres the code of the first iframe with the link

   <?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"

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

Notes: "the two codes are in 2 different iframes on the same page." Problem: "The first code loads on the same iframe where i clicked the link." Goal: "I need to load on the iframe named ="propdet" without reloading the contents of the other iframe".

share|improve this question
    
iframes are almost always a bad idea –  Dagon Jun 25 '13 at 2:49
    
You could suggest the code, i just need to make it work.. T.T –  Jr Denorte Jun 25 '13 at 2:50
    
and i need to stop seeing people improperly use iframes. –  Dagon Jun 25 '13 at 2:52
    
my bad @dagon , could u suggest how could i make it work? –  Jr Denorte Jun 25 '13 at 7:56
    
` window.location.href = "propdetails.php?propid=" + javascriptVariable; ` i just want to make this target to an iframe –  Jr Denorte Jun 25 '13 at 7:57
add comment

1 Answer

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.

share|improve this answer
    
how can i target the " window.location.href = "propdetails.php?propid=" + javascriptVariable; " to the propdet iframe? –  Jr Denorte Jun 25 '13 at 7:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.