Magento Forum

Trying to create a mouseover popup tag, but having trouble calling product name and price. Any help? 
 
thomasmore
Sr. Member
 
Total Posts:  80
Joined:  2008-10-21
 

Okay, I’ve been trying to bring up a css box with the product name and price on mouseover. So far, I can get the css box to pop up once you mouseove the product, but how do you call the product name and price so it appears inside the box?

Below is the code from list.phtml:

<a href="<?php echo $_product->getProductUrl() ?>” id="infotextid1">

This is the javascript to bring up the box:

<script type="text/javascript\">

var helptexts = [

//Pace where product name/price should be
‘ ***************AREA THAT NEEDS PRODUCT NAME*********** ‘,
];

function showbox(e) {
if (!e)
var e = window.event;
var linkID = e.srcElement? e.srcElement.id : this.id;
var helpbox = document.getElementById(’infobox’);
helpbox.innerHTML = ‘Product:’ + helptexts[linkID.substr(10) - 1];
helpbox.style.display = ‘block’;

var posx = (typeof e.pageX!= ‘undefined’)? e.pageX : e.clientX + (document.documentElement? document.documentElement.scrollLeft
: document.body.scrollLeft);

var posy = (typeof e.pageY!= ‘undefined’)? e.pageY
: e.clientY + (document.documentElement? document.documentElement.scrollTop
: document.body.scrollTop);

<!-- set x-axis and y-axis position for displaying helpbox/tipbox here -->
helpbox.style.top = posy - 20 + ‘px’;
helpbox.style.left = posx + 10 + ‘px’;

}

<!-- code for hidding helpbox -->
function hidebox() {
document.getElementById(’infobox’).style.display = ‘none’;
}

<!-- Code for Initializing helpbox [Attaching Mouseover, Mouseout event for helpbox] -->
function init() {
var hrefs = document.getElementsByTagName(’a’);
for (var i = 0; i < hrefs.length; i++) {
if (hrefs.id.substr(0,10) == ‘infotextid’) {
if (hrefs.attachEvent)
{
hrefs.attachEvent(’onmouseover’, showbox);
hrefs.attachEvent(’onmouseout’, hidebox);
}
else if(hrefs.addEventListener)
{
hrefs.addEventListener(’mouseover’, showbox, false);
hrefs.addEventListener(’mouseout’, hidebox, false);
}
}
}
}
</script>

<div id="infobox"></div>
<script type="text/javascript\">
init();
</script>

 
Magento Community Magento Community
Magento Community
Magento Community
 
Discovery
Enthusiast
 
Total Posts:  767
Joined:  2007-12-29
 

getAttributeText(’name’) might be it. There is a function for prices, formatPrice($this->getPrice()) is what is used elsewhere, it puts the currency sign in, I believe…

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top