Jump to content

php echo in a popup


deamon1767

Recommended Posts

<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  :shy:

etc

 

window.onload = function(){

var text = document.getElementById("getH1").innerHTML;

alert(text);

}

 

Oh bugger sorry bout double post quote not modify :(

Link to comment
Share on other sites

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
Share on other sites

  • 2 weeks later...

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.