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> 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? 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 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? 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? 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? 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> 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> 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> 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?) 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
Archived
This topic is now archived and is closed to further replies.