Newbie needs help! |
Post Reply |
Author | |
pmkoenig
Newbie Joined: Oct 08 2014 Location: USA Status: Offline Points: 7 |
Post Options
Thanks(0)
Posted: Oct 10 2014 at 4:26pm |
Help!! I am new so bear with me if this is a stupid question. I am trying to change the color of an item on my page based on input from the user. Sort of like shopping pages were you can see something in different colors by clicking on the color. I don't want to open a new page - just change the color of the image on the current page. I hope this makes sense. Can I do this and if so how! Thanks!
|
|
Dmit OE
Admin Group Joined: May 31 2012 Status: Offline Points: 5283 |
Post Options
Thanks(0)
|
Hi,
Nothing stupid about the question. But please clarify what you want to obtain: do you want another image to be loaded into a certain element, do you want to hide an element and display another one, or is it enough to change background color of something, etc. Good day D |
|
pmkoenig
Newbie Joined: Oct 08 2014 Location: USA Status: Offline Points: 7 |
Post Options
Thanks(0)
|
I have the image in all the different colors - so I don't really know if I want to load another image or hide an element and display another one. I do know that it is not changing any backgound colors. I guess I don't know enough to know the difference. Is one better, faster, cleaner or easier??? I know that I'm not really helping - but I'm not really sure how to answer. Sorry and Thanks for the help!!!!
|
|
pmkoenig
Newbie Joined: Oct 08 2014 Location: USA Status: Offline Points: 7 |
Post Options
Thanks(0)
|
Maybe this will help. You know how you go to some sites and see a widget. The widget somes in 5 colors and you can click on a color and the widget will show up on the screen in that color. That is what I need to di. I hope this helps!!! Thanks Again!!!!!
|
|
Dmit OE
Admin Group Joined: May 31 2012 Status: Offline Points: 5283 |
Post Options
Thanks(0)
|
Yes, I understand the visual effect you want to obtain. There are several ways to do it, depending on the situation.
If all the images have the same size (dimensions) and you want the change to always happen fast (without waiting to load each specific image AFTER user has clicked a color), here's what I suggest, it is called "Image Sprites". - Note the height of an image, for example 100px. - With any picture editor (even standart Microsoft's Paint will do), put all the images one under another into one single image, like this: [] [] [] [] [] - Use this image as a background for a Frame element (or some other elements, even an empty Image element if you want) - Now, if you preview your page, you will see first of your images (you need of course to set the size of the element to match the size of 1 image) - Add your color "trigger" elements - I suggest Frames - In Styles-Customize, set Background Color for each "trigger", and Cursor to "pointer". - In Properties of each "trigger", set Personalized class to "color1" (for first), "color2" (for second) etc. In Properties of your image container element, set Personalized class to "colorimages". - Now the magic part: add Code Block (Source) type Javascript position Headers, with the code: $(function(){ // standard jQuery "shortcut" code, to execute after page structure loads $('.color1').click(function(){ // happens on clicking 1rs color trigger $('.colorimages').css('background-position', '0px 0px'); }); $('.color2').click(function(){ // happens on clicking 1rs color trigger $('.colorimages').css('background-position', '0px 100px'); // 100 is the image height, change! }); $('.color3').click(function(){ // happens on clicking 1rs color trigger $('.colorimages').css('background-position', '0px 200px'); // 200 is 2 x image height , change! }); // and so on for each trigger }); |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |