The radio buttons when selected work fine in terms of outputting a selected color via the radio buttons onto the page or screen.
Each radio button represents a different color.
I was wondering if it's possible with some java script to be able to manipulate the contrast of each selected color.
For example by constantly clicking the Color+ button, I should be able to achieve a darker contrast for a selected radio button color via java-script, but how?
<script>
//The function inform is invoked when the user clicks the button
function inform()
{
alert("You have activated me by clicking the grey button! Note that the event handler is added within the event that it handles, in this case, the form button event tag")
}
</script>
<form>
<input type="button" name="test" value="Color+:" onclick="inform()">
</form>
<!--Given this javascript code:
Is there a way to make the value of the button actually change
the selected color's contrast to a darker contrast, such that if the user keeps pressing the button by clicking the mouse button while
on a selected color via the radio button, the selected color's contrast becomes becomes darker.-->
<form name="go">
<input type="radio" name="C1" onclick="document.bgColor='lightblue'">
<input type="radio" name="C1" onclick="document.bgColor='pink'">
<i开发者_StackOverflow中文版nput type="radio" name="C1" onclick="document.bgColor='yellow'">
<input type="radio" name="C1" onclick="document.bgColor='lime'">
<!--Currently the user can select different colors via the radio box's.
But I wanted to somehow, have the click-eable box linked to the radio selections, such that when a color is selected
I can also change the color's contrast and make it dark.-->
</form>
Use an RGB -> HSV algorithm to get a color model where you can easily change the lightness of a color and then convert the color back to RGB.
精彩评论