Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

More obvious Radio button? 2

Status
Not open for further replies.

Will192

Technical User
Nov 15, 2002
111
US
What I need is a radio button that is more obvious when it is selected. Is there a way that I can make the button part bigger? Is there a way that I can change the color of the text if the radio button is selected?

Thanks in advance for any responses to this post.

Will192
 
there is no way to make the actual button larger but you can make the bgcolor change and any text associate on the page to the effect after the click event occurs
eg:
<tr>
<td>
<input type=&quot;radio&quot; onClick=&quot;this.style.backgroundColor='red'&quot;>Click Me!
</td>
</tr>

____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811

onpnt2.gif
 
BTW
that was jsut a example. A poor one too. if you have a event like the onClick in the button then you need to set the event to select the button as that will not occur if you do not.
eg:
<input type=&quot;radio&quot; onClick=&quot;this.style.backgroundColor='red';this.checked=true&quot;>Click Me!

____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811

onpnt2.gif
 
Using IE 5.5 and Nestcape 6.0.in a Windows 2000 PC. I get two different results but surely the look of the radio has been changed.



<input type=&quot;radio&quot; name=&quot;bigbluebutton&quot; style=&quot;background-color:blue;border:thin solid black;width:65px;height:65px&quot;>



grtfercho çB^]\..
&quot;Imagination is more important than Knowledge&quot; A. Einstein
 
Thanks for the replies. I got that working, but when I select another radio button in the set, the color stays. How do I set it up so that the color changes back when another radio button in the set is clicked?
 
you'll need to loop through the group and get which is selected and such.
example:

____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811

onpnt2.gif
 
I got to cook this small script.

All this is based on the <label> tag and a strict identification method.
You have to Id your radio boxes as a concatenation between the name of the group and the value of the radio box.
The ID of each label is the prefix 'lbl' plus the ID of the particular radio box.

As an added bonus when using the <label> tag you can click on the string and you'll select the option as well (kinda how VB lets you build forms).

_________________________________
<head>
<script type=&quot;text/javascript&quot;>


function showselect(elem){

var thegroup=eval('document.'+elem.form.name+'.'+elem.name);
var txtElem;//holds a string with the full id of the label
var thelabel; // holds the actual <label>
for(var index=0;index<thegroup.length;index++){
txtElem='lbl'+thegroup[index].id;
thelabel=document.getElementById(txtElem);
thelabel.className='radionormal';
}

//once all of them are reset then change the currently selected
txtElem='lbl'+elem.id;
thelabel=document.getElementById(txtElem);
thelabel.className='radioselected';


}
</script>
<style>
.radionormal{
background-color:transparent;
border:thin black none;
font-weight:normal;
color:black;

}
.radioselected{
background-color:red;
border:thin black solid;
font-weight:bolder;
color:white;

}

</style>
</head>
<body>

<form name=&quot;anyname&quot;>

<label for=&quot;radioset1&quot; id=&quot;lblradioset1&quot; class=&quot;radionormal&quot;>
<input type=&quot;radio&quot; name=&quot;radioset&quot; value=&quot;1&quot; id=&quot;radioset1&quot; onclick=&quot;showselect(this);&quot;>&nbsp;American Dollars</label>
<br>
<label for=&quot;radioset2&quot; id=&quot;lblradioset2&quot; class=&quot;radionormal&quot;>
<input type=&quot;radio&quot; name=&quot;radioset&quot; value=&quot;2&quot; id=&quot;radioset2&quot; onclick=&quot;showselect(this);&quot;>&nbsp;Canadian Dollars</label>
<br>
<label for=&quot;radioset3&quot; id=&quot;lblradioset3&quot; class=&quot;radionormal&quot;>
<input type=&quot;radio&quot; name=&quot;radioset&quot; value=&quot;3&quot; id=&quot;radioset3&quot; onclick=&quot;showselect(this);&quot;>&nbsp;UK Pounds</label>
<br>
<label for=&quot;radioset4&quot; id=&quot;lblradioset4&quot; class=&quot;radionormal&quot;>
<input type=&quot;radio&quot; name=&quot;radioset&quot; value=&quot;4&quot; id=&quot;radioset4&quot; onclick=&quot;showselect(this);&quot;>&nbsp;Yens</label>
<br>

</form>

</body>

grtfercho çB^]\..
&quot;Imagination is more important than Knowledge&quot; A. Einstein
 
I have gotten it to work through onpnt's link. My problem now is that I can't set the backgroud color initally. I have tried calling the procedure on the ONLOAD event of the form or the radio buttons, but the radio buttons aren't defined yet at that point.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top