I am trying to make a rubric using radio buttons. So far, I have a form with radio buttons and a section at the top for the grade. I’m wondering if there is a way to program the grade section to automatically fill in with the percent of how many "GO" buttons are clicked.
I know the form looks a little wonky right now, but that was done quickly to adjust for showing what I’m talking about.
I’m pretty new to HTML and I feel like all of my Googling attempts have been fruitless thus far. Hopefully someone can help me out. Or tell me I’m just plain wrong and steer me in the right direction.enter image description here
2
Answers
As you didn’t provide your
code
and there are not enough details of "Howgrades
should work?" or "What is the purpose ofgrades
?". So, I build a concept that if a user clicks onGo
thengrades
willcount up
and if the user clicks onNo-Go
then it willcount down
. I usedJavaScript
to handle user interaction. You can adjust the concept according to your desire.Here is the
code
:It can be done with some JavaScript. You’ll need to select the HTML elements for where the percentage value goes, the form, and all of the radio inputs marked "Go". Then you can assign an anonymous function to the
onchange
property of the form element, count the number of "Go" inputs that are selected (theirchecked
property will be set totrue
), then do the math and assign the result to theinnerText
property of the element for the percentage value.This example does what you want: