How to make a onmouseover work in mysql catalog - php

I'm having difficulty creating a button on my catalog page, the catalog page returns either 8 15 or 20 products from a mysql database so i use a loop to pull each product out of the database, and i need a addtocart button which uses javascript to create an onmouseover effect the code is as follows
echo "<a href=\"catalog.php?buyproduct=$productNumber\" onmouseover=\"document.crt.src='images/addcrt_btn_dn.png'\"
onmouseout=\"document.crt.src='images/addcrt_btn.png'\">
<img src=\"images/addcrt_btn.png\" name=\"crt\" alt=\"Add to cart\" width=\"81\" height=\"24\"> </a>";
it displays the image properly but nothing happens when the mouse is put over the image. I'm guessing that this could be caused because since either 8 15 or 20 of these images are being created, the "name=crt" is throwing the whole thing off, if so how could i fix this?
Any advice would be helpful thank you!

Instead of using the name attribute on the <img>, I would start by recommending you use the id attribute, as follows:
<img id="crt" />
Then you can change the src as follows:
document.getElementById('crt').src = 'images/addcrt_btn_dn.png';
Make sure you properly escape all those quotes properly, or work on generating the content another way (here's an example sticking with the name attribute):
...
?>
<a href="catalog.php?buyproduct=<?php=$productNumber?>" onmouseover="document[crt].src='images/addcrt_btn_dn.png'" onmouseout="document[crt].src='images/addcrt_btn.png'">
<img src="images/addcrt_btn.png" name="crt" alt="Add to cart" width="81" height="24">
</a>
<?php
...

Related

Problems with anchor tag - PHP

I wrote some code for a real estate website and I have a little problem.
When I click on an ad, I want to make the page go back at the line. In order to do that I use the anchor but it doesn't work.
In the main page I've put this
In the page of the ad detail I've put this:
<a href="affitti.php?location=<?php echo $do_query[location];?>&&lang=<?php echo $lang;?>#<?php echo $do_query[id];?>" >
It has to return at the number id of the anchor, but it doesn't go back either.
Can anyone help me?
It seems that you don't have the anchor per se. Check that is not missing:
<a name="anchor"></a>
Click here to go anchor
either use the name attribute as Marcos explains in his answer or an id
see below
<a id="<?php echo $do_query[id];?>"></a>
and
<a href="affitti.php?location=<?php echo $do_query[location];?>&lang=<?php echo $lang;?>#<?php echo $do_query[id];?>" >
the first placeholder needs to have an id set and the actual link will reference the placeholder by #id

Assign button image to links from db

php newbie. echoing out links to product pages, the following code works fine:
<a href="<?php echo $rows[$product_buy];?>"<p>Click Here for Details</p></a>
but, would like to change text link "Click Here..." to an image of a button.
tried different ways, searched around, still haven't figured it out
You could simply style your link to look like a button (by giving it a class/id to make sure not all links are targeted) or you can put an img tag between the a tag.
<img src="path_to_img" alt="">

Compress/Alternative code:-

I spent half a day writing the content section of my index page of my website but when I tried adding another image to the list of images (There is currently 6) it was a very long and annoying process. (Website: http://rikahiyuka.com)
Is there a way to write the code so that it will be easier to add more buttons (The Images)?
Things that are linked per image listed:
- JQuery
- Div (Link)
The most annoying part is adding to the JQuery.
Is there a better way to write the code for the buttons/images in the content section so it is more compact and easier to edit?
Note: The only section of the index.php file that uses PHP is the footer for the year number.
Instead of doing each image individually, just write one function:
function showhide(shownum) {
$("#Ip1, #Ip2, #Ip3, #Ip4, #Ip5, #Ip6").hide();
$("#Il1, #Il2, #Il3, #Il4, #Il5, #Il6, #IDTopic").hide();
$("#Ip" + shownum + ", #IDTopic, #Il" + shownum).show();
}
Then, if you want to show something, you simply call this function:
showhide(6);
You can put it in your HTML (like so:)
<td>
<img id="Iimg1" class="c-img" src="#" title="Show 1" onclick="showhide(1) />
</td>
or edit your JavaScript:
$("#Iimg1").click(function(){
showhide(1);
});
Replacing 1 with whichever link you want to show. This will make it much quicker and much less annoying because you won't have to list out each element to show and hide. Just call the showhide function :) It basically works by, instead of worrying about hiding everything except the one clicked on, hiding ALL of the links. Then, showing the one requested.

magento product attribute with wysiwyg, src="{{media url="image.jpg"}} not parsed

Hi I'm working with Magento 1.7
I create a text area attribute with wysiwyg allowed and visible on the product page.
when I insert an image I can see only the html text of the attribute, images don’t appear.
If I analyse the generated html code, I can see that the code included by the wysiwyg editor like
src="{{media url="image.jpg"}}
has not been parsed.
The code I use is:
echo $ _Product-> getData ('technical_support');
I tried to print the attribute with
echo $this->helper('cms')->getBlockTemplateProcessor()->filter($this->helper('catalog/output')->productAttribute($this->getProduct(), nl2br($_technical_support), 'technical_support') );
But the attribute is not printed
How can I fix it?
Thanks for your help.
This is how u have to call the images through wysiwyg editor. You have to click show/hide button. Then u can write html tags there. Here is the example
<p class="home-callout"><img src="{{skin url='images/ph_callout_left_rebel.jpg'}}" alt="" /></p>
Flower brackets are missing in ur code.
And for attribute, your process is wrong.. Follow this link Calling an attribute in a CMS block in magento

loading external pages within website

I have a table in database which stores links submitted by users, I want my users to use those links whenever they want but the problem i am facing is
I can retrive and display the links with this code
<td width="560"><font color="#999">
'.$row['link'].'
</font>
</td>
but it generates link like this
http://XYZ.com/www.pxleyes.com/blog/2011/12/these-50-photos-will-blow-you-away/?action=tagtoload
so when the users click on this links it says page not found.
I want to open the links within my page so i have added ?action=tagtoload
which will load pages within my page with ajax call but the things are not working.
yes XYZ.com is my domain and for not generated links xyz.com/abc?action=tagtoload is working fine. its coming just below top header i want all external links to be below my header. can you please tell how i can open these links under my header. I want to display these links as anchored link so that user can see what these items are and when users clicks on these links it should open in iframe or whatever but under my header –
Guessing that XYZ.com stands for your domain:
add http:// for external links
Concerning the ajax-Problem:
Is it working with fixed, not generated links? Please post also the output of the php file and your ajax-code.
Please also define 'in you page': In an iframe? div? replacing your window?
EDIT:
To 'fix' you 'php-code':
<td width="560">
<font color="#999">
<a href="<?php print $row['link'] ?>?action=tagtoload" class="tagToload">
<?php print $row['link'] ?></a>
</font>
</td>
Please get familiar with html and php first.
do NOT use <font>, use css instead
use css instead of putting the width in the td as an attribute
read http://php.net/

Categories