Welcome Guest [Log In] [Register]
This board has been archived and is no longer accepting new questions. If you have a support question for your ZetaBoard, please visit us at the new support board. Registration is free and easy.


Visit the NEW ZetaBoards Support forum!

Username:   Password:
Add Reply
‽ jQuery Add Colors; Easier adding of colors to the dropdown
Topic Started: Feb 10 2008, 04:08 PM (2,507 Views)
Interrobang
Member Avatar
Yeah, I went there.
[ * ]
Code: HTML
 
<script type="text/javascript">
//<![CDATA[
$(function() { if($('select[name=fcolor]').length) {
var colors = {
'Mega-Awesome Blue' : '5a70b3',
'Rather-Okay Red' : 'aa0000'
};
for (color in colors)
$('select[name=fcolor]').append($('<option></option>').attr('value','#' + colors[color]).text(color));
}});
//]]>
</script>


  • No copyright needed.
  • jQuery version; is faster than other posted versions.
  • Change 'Mega-Awesome Blue', etc. to the name that should appear in the dropdown.
  • Change the hex code after each name to the hex of the color.
  • If you want to add more, just put a comma after each name:hex pair, except the last one.
Offline Profile Quote Post Goto Top
 
Nicola
Darth Vader's Sewing Instructor

Yummy. jQuery. I am glad to see someone using proper syntax also ;)
Offline Profile Quote Post Goto Top
 
ZapTap
Member Avatar
Member
[ *  *  *  * ]
yay, go interrobang!!! ^_^
Offline Profile Quote Post Goto Top
 
lirts
Member Avatar
Member
[ *  *  * ]
where do you put it?
Offline Profile Quote Post Goto Top
 
Interrobang
Member Avatar
Yeah, I went there.
[ * ]
Doesn't matter. You can put it where the rest of your scripts go, so they're all in one place.
Offline Profile Quote Post Goto Top
 
Ambrosia
Member
[ *  * ]
Nice!
It's definately more simplied that other codes.
Too bad it's limited to 5 additional colours, but that's probably how ZB is coded.
The other one I used 'accidently' showed the colour in the drop down menu.
Which was quite nice, compared to the theme's default colour.
Any would you could add that to your code?
I mean like when you open the drop down menu it displays the colours as it is in the script.
The correct colours, not the default theme colour.
Would be a nice touch for the general forum user.

Great work work though, I really appreciate it.
Offline Profile Quote Post Goto Top
 
Xoidmin
Member
[ *  * ]
That's a really nice code!
Offline Profile Quote Post Goto Top
 
Elisha
Member
[ * ]
It dosent work for me.. where do you add the script ?
I've tried it in fOOTERS and Javascripts..
Offline Profile Quote Post Goto Top
 
Ambrosia
Member
[ *  * ]
Elisha
May 25 2008, 07:13 AM
It dosent work for me.. where do you add the script ?
I've tried it in fOOTERS and Javascripts..
In below the board I think or above either one of those 2.
Copy the code string by string and paste it in your board template.
It should work, if you copy the whole code it will get screwed up.
So in otherwords after placing it in your board template make it look like the way it was posted.
Offline Profile Quote Post Goto Top
 
.Koda
Member Avatar
Livin' The Life
[ *  * ]
Is JQuery Reliable?

And what exactly is it?
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · User Created Codes · Next Topic »
Add Reply