php - How to make a onmouseover work in mysql catalog -


I'm having difficulty creating a button on my catalog page, the catalog page returns an 8x or 20 products from a MySQL Is the database so I use a loop to drag out each product from the database, and I need an addtocart button which uses javascript to create an onmouseover effect The code is as follows

   code   

This displays the image properly, but nothing happens when the mouse is placed on the image, I'm guessing it's the cause Because either 8 or 15 images are being created, "name = CRT" is throwing the whole thing, if so, how can I fix it?

Any advice would be helpful!

Instead of using the name attribute on & lt; Img & gt; , I recommend using the id attribute, as follows:

  & lt; Img id = "crt" />  

Then you can change src as follows:

  document.getElementById ('crt'). Src = 'diagram /addcrt_btn_dn.png';  

Ensure that you run away properly from those quotes, or work on preparing the content in another way (here with the name attribute The adhesive is an example):

  ...? & Gt; & Lt; A href = "catalog.php? Buyproduct = & lt ;? php = $ product number? & Gt;" Onmouseover = "document [crt] .src = 'images / addcrt_btn_dn.png'" onmouseout = "document [crt] .src = 'images / addcrt_btn.png'" & gt; & Lt; Img src = "picture / addcrt_btn.png" name = "crt" alt = "add to cart" width = "81" height = "24" & gt; & Lt; / A & gt; & Lt ;? Php ...  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -