[SOLVED] color-box selections

This is a discussion on "[SOLVED] color-box selections" within the JavaScript Forum section. This forum, and the thread "[SOLVED] color-box selections are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Dec 12th, 2007, 12:05
Junior Member
Join Date: Oct 2007
Location: Holland
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] color-box selections

hi all,

I am trying to create a small block, consisting of color boxes.
Roughly, my structure is something of the sort:

<ul>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
...
<ul>

I want to change the look of the <li>-s on mouse hover and do another change when a color box is clicked.

the color set is dynamically obtained with .jsp and that's why I cannot just create a css class for every color box.

Can you tell me a standard solution for such a problem. Do I have to change the background image of the <li> tag, or I'd better insert a <img> tag within the link. Do I have to use JavaScript for that?

I tried to change the background attribute of the <li> using document.getElementById(li_id).style.background=". ..." but it didn't work.


Thanks
Reply With Quote

  #2 (permalink)  
Old Dec 12th, 2007, 16:40
Reputable Member
Join Date: Apr 2007
Location: Scotland
Age: 17
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Blake121
Re: color-box selections

Try something like:

Code: Select all
document.getElementById(li_id).style.background=" url('my-background.png') ";
Reply With Quote
  #3 (permalink)  
Old Dec 12th, 2007, 22:01
Junior Member
Join Date: Oct 2007
Location: Holland
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Re: color-box selections

amazing, I tried all kinds of style.background / style.backgroundImage combinations, with all sorts of quotes - single, double and semicolons.

In the end the "winning combination" was:

elem.style.backgroundImage = "url(images/image.gif)";


cheers.
Reply With Quote
  #4 (permalink)  
Old Dec 12th, 2007, 22:09
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,772
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: color-box selections

Could you please mark this as solved via thread tools! Thanks.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #5 (permalink)  
Old Dec 21st, 2007, 14:48
Junior Member
Join Date: Oct 2007
Location: Holland
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Re: [SOLVED] color-box selections

hi
As I explained in the previous posts, I need a sequence of color boxes for a color selection. I implemented this as an unordered list and each <li> element has the corresponding color as a background picture.
Onmouseover I change the background of the <li> with another picture, using:

elem.style.backgroundImage = "url(images/image.gif)";

However, the images flicker and the user experience is therefore spoiled.

Can you suggest another possible implementation for this purpose?

Thanks!
Reply With Quote
  #6 (permalink)  
Old Dec 21st, 2007, 19:24
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: color-box selections

You can just use css for this..

Place links inside the li's and define some CSS

Code: Select all
li a:link, li a:visited
{
/*Standard colour */
    background-image: url(images/image1.gif);
}
li a:hover
{
/*mouseover */
     background-image: url(images/image2.gif);
}
li a:active
{
   /*clicked*/
    background-image: url(images/image3.gif);
}
Just give each a an id or specific class and style in the above fashion....

Cheers,
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
  #7 (permalink)  
Old Dec 22nd, 2007, 20:57
Junior Member
Join Date: Oct 2007
Location: Holland
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Re: color-box selections

yup, you are right! I'll try it through css, thanks
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Links not the right color motormaniac Web Page Design 5 Dec 9th, 2007 09:25
[SOLVED] Change Input Textbox Background Color tejaxx JavaScript Forum 4 Nov 19th, 2007 20:16
[SOLVED] Link Color and problem with Image positioning! Ed Web Page Design 33 Oct 10th, 2007 11:17
[SOLVED] Zebra Row Color &lt;DIV&gt; Monie Web Page Design 19 Oct 10th, 2007 03:07
selections within textareas benbacardi JavaScript Forum 16 Feb 16th, 2005 13:59


All times are GMT. The time now is 05:48.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43