Solved

Radio button style

Posted on 2010-11-16
7
1,340 Views
Last Modified: 2012-05-10
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
0
Comment
Question by:charlie324
  • 3
  • 2
  • 2
7 Comments
 
LVL 3

Expert Comment

by:Mestika
Comment Utility
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
 
LVL 6

Author Comment

by:charlie324
Comment Utility
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
 
LVL 3

Expert Comment

by:Mestika
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 6

Author Comment

by:charlie324
Comment Utility
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
 
LVL 6

Expert Comment

by:TheQuietShadow
Comment Utility
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
 
LVL 3

Accepted Solution

by:
Mestika earned 200 total points
Comment Utility
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
 
LVL 6

Assisted Solution

by:TheQuietShadow
TheQuietShadow earned 50 total points
Comment Utility
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

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now