- Posts: 10
- Thank you received: 3
Change Background Colour Dynamically
12 years 6 months ago #146869
by daza110
Change Background Colour Dynamically was created by daza110
I am wondering if the user can change the background colour of the image div.
I have a variety of different colour stickers, and I would like the user to select the colour of their "car" and then the colour of theie desired sticker to see what it would like like roughly against their car.
EG Is there car is RED they would select Red, this would then change the "hikashop_product_main_image" to a red background. Then they would select "White" as the colour and this would bring the White sticker up (I do this by uploading the relevent image to the product obviously).
My images are a transparent png format so you can see the background colour where the transparency is.
If this is possible that would be fantastic.
Alternatively i dont mind uploading several different images, and then having the hikashop_product_main_image" div calling the relevent image.
Any help would be great. Thanks
I have a variety of different colour stickers, and I would like the user to select the colour of their "car" and then the colour of theie desired sticker to see what it would like like roughly against their car.
EG Is there car is RED they would select Red, this would then change the "hikashop_product_main_image" to a red background. Then they would select "White" as the colour and this would bring the White sticker up (I do this by uploading the relevent image to the product obviously).
My images are a transparent png format so you can see the background colour where the transparency is.
If this is possible that would be fantastic.
Alternatively i dont mind uploading several different images, and then having the hikashop_product_main_image" div calling the relevent image.
Any help would be great. Thanks
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 12953
- Thank you received: 1778
12 years 6 months ago #146911
by Mohamed Thelji
Replied by Mohamed Thelji on topic Change Background Colour Dynamically
Hi,
The best solution will probably be to directly add different images with the good background , because if you want to dynamically change the CSS regarding the selected characteristic, you'll have to do some code customization which will require development skills.
The best solution will probably be to directly add different images with the good background , because if you want to dynamically change the CSS regarding the selected characteristic, you'll have to do some code customization which will require development skills.
Please Log in or Create an account to join the conversation.
12 years 6 months ago #146937
by daza110
Replied by daza110 on topic Change Background Colour Dynamically
I have some basic skills in PHP and jQuery, slightly more advanced in CSS and HTML but upon investigation I found a nifty little colour picker plug-in, see it in action here on my site.
www.thetrailerbox.com/shop/categories/ca...-stick-figure-family
www.thetrailerbox.com/shop/categories/ca...-stick-figure-family
Please Log in or Create an account to join the conversation.
12 years 6 months ago #146945
by Eliot
Replied by Eliot on topic Change Background Colour Dynamically
Good job!
Thank you for sharing this with us, don't hesitate to post the name of the plugin you used, it might help other people
Thank you for sharing this with us, don't hesitate to post the name of the plugin you used, it might help other people
Please Log in or Create an account to join the conversation.
12 years 6 months ago - 12 years 6 months ago #146963
by daza110
Replied by daza110 on topic Change Background Colour Dynamically
www.eyecon.ro/colorpicker/
The way I got this to work was with using the following in the <head> part of my index.php
and then changing line 48 in the layout.js from
$('#colorSelector div').css('backgroundColor', '#' + hex);
to
$('#hikashop_product_image_main').css('backgroundColor', '#' + hex);
You also have to add in the following code to the product / show.php in hikashop display.
<div id="colorSelector">
<div style="background-color: rgb(255, 0, 43);"></div>
</div>
Ohh and dont forget to create some width and height CSS styling for #colorSelector div otherwise you will be swearing like I was as to why it wasnt working!!
Hope this will help someone in the future, If so wouldn't mind a Thank You
The way I got this to work was with using the following in the <head> part of my index.php
Code:
<link href="/css/colorpicker.css" type="text/css" media="screen" rel="stylesheet">
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/colorpicker.js"></script>
<script type="text/javascript" src="/js/eye.js"></script>
<script type="text/javascript" src="/js/utils.js"></script>
<script type="text/javascript" src="/js/layout.js></script>
and then changing line 48 in the layout.js from
$('#colorSelector div').css('backgroundColor', '#' + hex);
to
$('#hikashop_product_image_main').css('backgroundColor', '#' + hex);
You also have to add in the following code to the product / show.php in hikashop display.
<div id="colorSelector">
<div style="background-color: rgb(255, 0, 43);"></div>
</div>
Ohh and dont forget to create some width and height CSS styling for #colorSelector div otherwise you will be swearing like I was as to why it wasnt working!!
Hope this will help someone in the future, If so wouldn't mind a Thank You
Last edit: 12 years 6 months ago by daza110.
Please Log in or Create an account to join the conversation.
Time to create page: 0.191 seconds