I need to create a priority field in my HTML form. Currently i am using radio buttons but it does not suffice my needs. The radio button should change background color onclick depending on the level of priority. Also i am not able to read the values to the controller.
The priority field should change colors according to the matrix above. In the form only the first row is present for the priority field. This is the HTML i am using for priority
` <input type="radio" id="1" class="priority">
<input type="radio" id="2" class="priority">
<input type="radio" id="3" class="priority">
<input type="radio" id="4" class="priority">
<input type="radio" id="5" class="priority">`
I am using spring MVC framework.
Any help would be appreciated
As per your requirement you can use jQuery plugin Colourful rating system. It comes with good options so that you can set the color as required.
DEMO
example as follows:
the HTML
CSS
After we're done loading jQuery and the Color plugin, we're ready to use jQuery to now animate the circles to the right colour and display the text.
for complete documentation and source code click HERE
I am not sure if i understud your question correct, but if so this demo code (jsfiddle) might help. (its just a demo, and would still have to be adapted for your needs)
It simply sets the color class on the Click event of every RadioButton.
CSS
HTML
Script
tested with Chrome 34+
UPDATE: updated FIDDLE
add
value
attribute to the radio buttons likethen some script to read the radio button values like:
I've tried some workaround for the sake of "changing color" in this Fiddle
Added this html, to act as the radio buttons that changes color:
with this css, to take it under the radio buttons:
Then add
z-index: 9
to the radio button css rule to make it stay on top of the.circ
divs and be clickable. Finally, addopacity: 0
to make it invisible, so the.circ
divs under will appear on screen. Now you can change the color of the.circ
divs accordingly using some script.PS: You can't just edit radio button's background color, instead use background images