PDA

View Full Version : Help with radio buttons


seanknighton
11-03-03, 06:55 PM
I'm trying to figure out how to make text next to a radio button bold upon clicking, and unbold upon unclicking. If anybody has an idea I would greatly appreciate it!!! THANKS

evo4ever
11-14-03, 07:22 PM
You could use a layer for this. When the event "onClick" is invoked it could reappear a hidden layer with your bold text, this will go over the unbold text :)

evo4ever
11-14-03, 07:48 PM
I've just banged up a quick example. Go here: http://evo.zeroninja.co.uk/radiobold.htm . Is that what you want?

PS: This won't work in NS because im using the IE layers object, but this is easily fixable.

seanknighton
11-14-03, 09:50 PM
Thanks for your input!! I appreciate it. I tried messing around with your script but I don't think it'll work like I would like it. If possible I'm looking for something a little more simple... I'm writing this script to accompany the website: http://www.searchyourplanet.com Maybe you could take a look at the site and see if you have any ideas how I could implement a bold/unbold script into it easily...

THANKS

I've just banged up a quick example. Go here: http://evo.zeroninja.co.uk/radiobold.htm . Is that what you want?

PS: This won't work in NS because im using the IE layers object, but this is easily fixable.

evo4ever
11-15-03, 11:19 AM
My script does do the job, but it needs to be implemented on a larger scale, for instance your site. If you want I could do it for you.

melsana
11-17-03, 11:40 AM
Another way that I think is a little more simple is this.

Javascript code:

function makeBold(num) {
for ( i=0; i<document.test.rad.length; ++i ) {
if ( i == num ) {
var myID = document.test.rad[num].value
document.getElementById(myID).style.fontWeight = "bold";
} else {
var myID = document.test.rad[i].value
document.getElementById(myID).style.fontWeight = "normal";
}
}
}

body code:

<FORM name=test>
<INPUT value="r1" type=radio name=rad onClick=makeBold(0)><SPAN id="r1">Radio 1</SPAN>
<INPUT value="r2" type=radio name=rad onClick=makeBold(1)><SPAN id="r2">Radio 2</SPAN>
</FORM>


You must make sure that the id in the SPAN is the same as the value of the radio button for this to work.