deamon1767 Posted January 20, 2012 Share Posted January 20, 2012 I need to put the code below in a popup Any ideas? <h1><?php echo JHTML::link($product->link, $product->product_name); ?></h1> Quote Link to comment https://forums.phpfreaks.com/topic/255448-php-echo-in-a-popup/ Share on other sites More sharing options...
UrbanDweller Posted January 21, 2012 Share Posted January 21, 2012 <h1 id="getH1"><?php echo JHTML::link($product->link, $product->product_name); ?></h1> var text = document.getElementById("getH1").innerHTML; alert(text); see if that works? Quote Link to comment https://forums.phpfreaks.com/topic/255448-php-echo-in-a-popup/#findComment-1309714 Share on other sites More sharing options...
UrbanDweller Posted January 21, 2012 Share Posted January 21, 2012 <h1 id="getH1"><?php echo JHTML::link($product->link, $product->product_name); ?></h1> var text = document.getElementById("getH1").innerHTML; alert(text); see if that works? If your running script from html head remember to call it from inside window.onload anonymous function else top is fine im sure etc window.onload = function(){ var text = document.getElementById("getH1").innerHTML; alert(text); } Oh bugger sorry bout double post quote not modify Quote Link to comment https://forums.phpfreaks.com/topic/255448-php-echo-in-a-popup/#findComment-1309716 Share on other sites More sharing options...
deamon1767 Posted January 21, 2012 Author Share Posted January 21, 2012 I put <h1 id="getH1"><?php echo JHTML::link($product->link, $product->product_name); ?></h1> var text = document.getElementById("getH1").innerHTML; alert(text); but just printed var text = document.getElementById("getH1").innerHTML; alert(text); NO popup Am I missing something? Quote Link to comment https://forums.phpfreaks.com/topic/255448-php-echo-in-a-popup/#findComment-1309897 Share on other sites More sharing options...
trq Posted January 21, 2012 Share Posted January 21, 2012 Have you got your javascript inside a script tag? Quote Link to comment https://forums.phpfreaks.com/topic/255448-php-echo-in-a-popup/#findComment-1309902 Share on other sites More sharing options...
deamon1767 Posted January 22, 2012 Author Share Posted January 22, 2012 Huh? Quote Link to comment https://forums.phpfreaks.com/topic/255448-php-echo-in-a-popup/#findComment-1309924 Share on other sites More sharing options...
trq Posted January 22, 2012 Share Posted January 22, 2012 Javascript needs to go within a script tag. <script type="text/javascript"> // code in here </script> Quote Link to comment https://forums.phpfreaks.com/topic/255448-php-echo-in-a-popup/#findComment-1309930 Share on other sites More sharing options...
deamon1767 Posted January 31, 2012 Author Share Posted January 31, 2012 Still not working Heres my code: This code is inside a php page <script type="text/javascript"> var text = document.getElementById("getH1").innerHTML; alert(text); </script> <h4 id="getH1"> <?php echo JHTML::link($product->link, $product->product_name); ?><h/4> Quote Link to comment https://forums.phpfreaks.com/topic/255448-php-echo-in-a-popup/#findComment-1313115 Share on other sites More sharing options...
Volfirefighter Posted January 31, 2012 Share Posted January 31, 2012 Deamon1767 just to let you know if you would look at UrbanDweller second post on here you would have noticed he added alittle code in his quotes.. so if you would copy and paste this it should work like you want it to.. <script type="text/javascript"> window.onload = function(){ var text = document.getElementById("getH1").innerHTML; alert(text); } </script> <h4 id="getH1"> <?php echo JHTML::link($product->link, $product->product_name); ?></h4> Quote Link to comment https://forums.phpfreaks.com/topic/255448-php-echo-in-a-popup/#findComment-1313149 Share on other sites More sharing options...
deamon1767 Posted January 31, 2012 Author Share Posted January 31, 2012 I did and have but it just shows the popup with the link insde I need it to show the link as a page (iframe?) Quote Link to comment https://forums.phpfreaks.com/topic/255448-php-echo-in-a-popup/#findComment-1313152 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.