Connecting Tech Pros Worldwide Forums | Help | Site Map

Background-Color Attribute in Select

frank.sconzo@gmail.com
Guest
 
Posts: n/a
#1: Jan 20 '06
Greetings,

I was testing my web application on the Mac/Safari and noticed a
problem with the background color of the select input element.
Safari doesn't seem to pay any attention to the style I set for the
background color. The listbox ends up with a white background.
It works nicely in Internet Explorer and I would like to make it work
on Safari too.

Perhaps I am doing something slightly non-standard, or maybe there is a
better way to do this so that Safari will set the background color.

Any suggestions are welcome (besides abandoning the use of Safari, of
course :)

Here is the style:
select.menubar-select2 {
font-weight: bold; font-size: 8pt; color: #000000; font-family:
Arial, Helvetica, sans-serif; background-color: #CCCCCC
}

And here is the input element:
<select class="menubar-select2" name="View"
onchange="exec_menu_item(this);">
<option value="void(0);" selected>--- Choose one ---</option>
<option value="option1();">Option1</option>
<option value="option2();">Option2</option>
</select>

And some javascript for those wondering what exec_menu_item does...

<script language="JavaScript">
function exec_menu_item(control) {
var selection = control.selectedIndex;
if(selection != 0) {
var command = control[selection].value;
control.selectedIndex = 0;
eval(command);
} else {
alert("Top Level Option selected");
}
return false;
}
</script>


Thank you,
Frank


kchayka
Guest
 
Posts: n/a
#2: Jan 20 '06

re: Background-Color Attribute in Select


frank.sconzo@gmail.com wrote:[color=blue]
>
> I was testing my web application on the Mac/Safari and noticed a
> problem with the background color of the select input element.
> Safari doesn't seem to pay any attention to the style I set[/color]

Safari has very limited support for form styling, as do some other
browsers. You can't make a browser do what it isn't capable of doing, so
just forget about it and move on to something else.

--
Reply email address is a bottomless spam bucket.
Please reply to the group so everyone can share.
Gérard Talbot
Guest
 
Posts: n/a
#3: Jan 21 '06

re: Background-Color Attribute in Select


frank.sconzo@gmail.com wrote :[color=blue]
> Greetings,
>
> I was testing my web application on the Mac/Safari and noticed a
> problem with the background color of the select input element.
> Safari doesn't seem to pay any attention to the style I set for the
> background color. The listbox ends up with a white background.
> It works nicely in Internet Explorer and I would like to make it work
> on Safari too.
>[/color]

Which version (version number) of Safari ?
Which version (version number) of IE ?
[color=blue]
> Perhaps I am doing something slightly non-standard, or maybe there is a
> better way to do this so that Safari will set the background color.[/color]

Try this page:

http://www.gtalbot.org/DHTMLSection/...SSButtons.html
[color=blue]
>
> Any suggestions are welcome (besides abandoning the use of Safari, of
> course :)
>
> Here is the style:
> select.menubar-select2 {
> font-weight: bold; font-size: 8pt;[/color]

I would definitely not use "pt" as a length unit for font, furthermore
in a select. "pt" is good for printing, not for screen media.

W3C Quality Assurance tip for webmasters
Care with Font-size: Recommended practices

"# Do not specify the font-size in pt, or other absolute length units.
They render inconsistently across platforms and can't be resized by the
User Agent (e.g browser).
# Use relative length units such as percent or (better) em,(...)"

http://www.w3.org/QA/Tips/font-size#goodpractice

color: #000000; font-family:[color=blue]
> Arial, Helvetica, sans-serif; background-color: #CCCCCC[/color]

The select will have its background-color; the option background-color
does not inherit it.

inherited no
http://www.w3.org/TR/CSS21/colors.ht...ckground-color
[color=blue]
> }
>
> And here is the input element:
> <select class="menubar-select2" name="View"
> onchange="exec_menu_item(this);">
> <option value="void(0);" selected>--- Choose one ---</option>[/color]

The above code is improvable, perfectible, like this:

<option value="" selected="selected">--- Choose one ---</option>
[color=blue]
> <option value="option1();">Option1</option>[/color]

I believe you can't put javascript code like this in the value option.
Maybe what you do is possible, doable but it looks from what I see not
recommendable.
[color=blue]
> <option value="option2();">Option2</option>
> </select>
>
> And some javascript for those wondering what exec_menu_item does...
>
> <script language="JavaScript">[/color]

language is deprecated; type is required and is both backward and
forward-compatible. So:

<script type="text/javascript">
[color=blue]
> function exec_menu_item(control) {
> var selection = control.selectedIndex;
> if(selection != 0) {
> var command = control[selection].value;
> control.selectedIndex = 0;
> eval(command);[/color]

Ok. I see how you are handling those void(), option1(), etc.. but I
don't like this. It looks convoluted. Again, maybe what you do is doable
(I can't be sure) but I would not recommend what you do here.

value CDATA #IMPLIED -- defaults to element content --
http://www.w3.org/TR/html401/interac...f-value-OPTION

[color=blue]
> } else {
> alert("Top Level Option selected");[/color]

else
{
return true;
}
[color=blue]
> }
> return false;
> }
> </script>
>
>
> Thank you,
> Frank[/color]

You have not shown what those option1(); , option2(); function actually do.

Gérard
--
remove blah to email me
Closed Thread