Solved

Radio button style

Posted on 2010-11-16
7
1,345 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
ID: 34143129
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
ID: 34143158
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
ID: 34143216
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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 6

Author Comment

by:charlie324
ID: 34147945
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
ID: 34148468
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
ID: 34148999
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
ID: 34149030
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

785 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