...

View Full Version : control radio background colour via script?



babelfish
04-20-2005, 04:16 PM
Hi all,

i need a script that will override all the background colours of MANY radio buttons i have on a form (its HUGE!!!)

i have:



function doRadio() {

var rbg = document.body.all.tags("input");
for (var i = 0; i < rbg.length; i++)
rbg[i].bgColor= '#E6F4F4';
}


i think the principle is sound but obvously radio is a subgroup of INPUT... any ideas? :confused:

hemebond
04-20-2005, 10:19 PM
Try

rbg[i].backgroundColor= '#E6F4F4';
though I'm not sure you can even colour radio buttons. And check
rbg.type == 'radio'

glenmac
04-20-2005, 11:24 PM
<input type="radio" style="background :blue">

glenngv
04-21-2005, 04:22 AM
<input type="radio" style="background :blue">
That will make the square surrounding the circle blue in IE but nothing in FF. If what the poster actually wants is to color the inside of the circle, it's not possible.

glenngv
04-21-2005, 05:10 AM
sorry, doubled reply (blame it to our intermittent internet connection :mad:)

babelfish
04-21-2005, 09:44 AM
thanks for the input (no pun intended - its too early!) :thumbsup:




function doRadio() {

var rbg = document.body.all.tags('input');
for (var i = 0; i < rbg.length; i++) {
rbg[i].style.backgroundColor='#E6F4F4';
rbg[i].style.border='0';
}
}

that does it for all radio, check, text etc. the problem is that i need to just do it for radio buttons. i would normally do class="radio" etc but im using lotus notes for my database power and its WYSIWYG form elements ( i hand code the html tho ) means it is a pain in the (_,_) to change the 200+ radio buttons on this page! and i have another similar form to do.

surely this is possible isnt it?

Kor
04-21-2005, 09:51 AM
function doRadio() {
var rbg = document.getElementsByTagName('input');
for (var i = 0; i < rbg.length; i++) {
if(rbg[i].getAttribute('type')=='radio'){
rbg[i].style.backgroundColor='#E6F4F4';
rbg[i].style.border='0px';
}
}
}

correct an error. Note: this code wou'nt work for Mozilla. For moz radio's background has no meaning

babelfish
04-21-2005, 09:53 AM
crap!

i just did this:



function doRadio() {

var rbg = document.getElementsByTagName('input');
for (var i = 0; i < rbg.length; i++) {
if(rbg[i].type == 'radio') {
rbg[i].style.backgroundColor='#FFFFFF';
rbg[i].style.border='0';
}
}
}


thanks for the prompt response btw! :thumbsup:

any ideas which would be more browser compatible?

Kor
04-21-2005, 09:58 AM
function doRadio() {
var rbg = document.getElementsByTagName('input');
for (var i = 0; i < rbg.length; i++) {
if(rbg[i].getAttribute('type')=='radio'){
rbg[i].style.backgroundColor='#E6F4F4';
rbg[i].style.border='0px';
}
}
}

correct an error. Note: this code woun't work for Mozilla. For moz radio's background has no meaning

glenngv
04-21-2005, 10:21 AM
any ideas which would be more browser compatible?
I don't think there's a way for Moz-based browsers to color the radio button. As you will notice when you tab to set focus to radio button, the size of the control is only as big as the circle so there's nothing to color to. While in IE the size is bigger. Both browsers don't allow color inside the circle itself.

babelfish
04-21-2005, 10:33 AM
that doesnt matter... i really want them to be white BG anyway. i just control the border and BG of form inputs to make them fit the colour scheme... thanks for your help all!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum