Radio button style

Hello All,

I am trying to figure out if there is any way I can change the default green circle of the radio button with purple color?

Please can someone advise?

Thanks
LVL 6
charlie324Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
MestikaConnect With a Mentor Commented:
Hey Charlie,

You have to create two images which is called: radio-off.png and radio-on.png

just put them in the same directory as the HTML file. Every CSS and JavaScript is within the HTML so the only thing you have to do is the two images.

I've created an zip archive with the index.htm and the two images so you can test it. Get it here:

http://www.box.net/shared/go92l4yti5
0
 
MestikaCommented:
Hi,

if you are using a Windows PC with default desktop / color settings, the default radiobutton color is a blue dot, not green.

But nevertheless, the radiobutton can't be styled in CSS as such. You will need to use a combination of CSS and JavaScript to customize your radiobuttons.

Please let me know if that's the case or if I have misunderstood your question.

- Mestika
0
 
charlie324Author Commented:
Hi Mestika
Thanks for your input, yes I am on Windows PC using FF, please see the screen shot attached, its showing in green color.
Yes, I want to apply #554061to the inner circle of the radio button, please can you advice how can I go about doing this?
Your help/suggestion/advise would greatly be appreciated.
Thank you
C
radio.PNG
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
MestikaCommented:
Of yes of cause I forgot that Windows XP with FF showed them in green :-)

About your radiobuttons, you will have to create an image for a radiobutton active and one for a radiobutton inactive.

I could explaine the entire code with CSS and JS to you but I think that you would be more comfortable with some tutorials, so please look at these two pages:

http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/example/
http://www.maratz.com/blog/archives/2006/06/11/fancy-checkboxes-and-radio-buttons/

They both explain the styling of the radio / checkboxes and the first page shows how you can do it with only one image containing both an active and inactive radiobutton where the other page has a image for each type of radiobutton.

If you only want to keep the original style but change the color, it should be a fairly easy task just to Photoshop and colorize the green color into purple.

Please let me know if you have any further questions

- Mestika
0
 
charlie324Author Commented:
Hi Mestika
I did try to follow from the links above but did not have no luck on this yet ... please can you help in making one?
thank you
0
 
TheQuietShadowCommented:
Call me silly, but couldn't you just create two images... One for selected and one for unselected and use javascript to change them? You could even use a third image for highlighting the radio button on mouseover. It would be much more customizable this way.
0
 
TheQuietShadowConnect With a Mentor Commented:
I am including a sample that I know works in FireFox, but I don't know if it works in IE. You may have to tweek it to work in IE and will probably want to create your own images.

<html>
<head>
<title>Your first selection&nbsp; Your secon</title>
<script type="text/javascript">
var radio = 0;
function click(id) {
      if (id == "rb0")
      {
            document.getElementById("rb0").setAttribute("src", "Radio%20Button/on.png");
            radio = 0;
            document.getElementById("rb1").setAttribute("src", "Radio%20Button/off.png");
      }
      else
      {
            document.getElementById("rb1").setAttribute("src", "Radio%20Button/on.png");
            radio = 1;
            document.getElementById("rb0").setAttribute("src", "Radio%20Button/off.png");
      }
}
</script>
</head>

<body>
<span onclick="click('rb0');" style="cursor:pointer"><img id="rb0" src="Radio%20Button/off.png" alt="" height="22px" width="22px" style="position:relative;top:4px;" />
Your first selection</span>
<br />
<span onclick="click('rb1');" style="cursor:pointer"><img id="rb1" src="Radio%20Button/on.png" alt="" height="22px" width="22px" style="position:relative;top:4px;" onclick="click('rb1');" />
Your second selection</span>
</body>
</html>
 on off
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.