Jump to content

colored select input


meomike2000

Recommended Posts

i want to use a select input for users to choose a color,,,

 

but, i want to be able to do more than just write in the name of the color i would like to be able to actual put a color sample instead of the word or both....

 

any ideas on how to do somthing like that...

 

i tried this,

<option style="{background-color:#000000}" value="0" <?if ($bgcolor=="0") 
            {echo 'selected="selected" '; } ?> >black</option>
			<option style="{background-color:#0000cd}" value="1" <?if ($bgcolor=="1") 
            {echo 'selected="selected"'; } ?> >blue</option>

 

and the word and color display but kinda weird, if i put the mouse over the color for selection that color goes away and the other color selection shows color..

 

if mouse over the black the blue shows blue,, if mouse over the blue,,, then shows the color black, how can i get it to show the color all the time, or is there a better way to allow color selection from color samples not words..

 

thanks mike.....

Link to comment
Share on other sites

http://v2.easy-designs.net/articles/replaceSelect/

 

Very detailed tutorial on to do what I posted above. If you're looking forward to learning something new I'd recommend following it.

Keep in mind that it reduces accessibility. For example the arrow up/down keys don't change the value when it's selected unlike the real element, I'm sure there are also existing solutions for this presents in libraries like jquery/yui/mootools/mojo

Link to comment
Share on other sites

It did not for me when I tried adding background images to the background of a options, something like

<select>
  <option style='background-image: url( netherlands.png );'>Dutch</option>
  <option style='background-image: url( germany.png );'>German</option>
</select>

Though I can't remember when it was, so it might have been pre-ie7. If every visitor counts I'd double check in ie6/opera and one of the webkit based browsers such as konqueror, safari and/or chrome

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.