How to get data from radio button to JS?
Hi, using the FormData API, I got NaN
Code: https://jsfiddle.net/cs6qphtr/3/
8 Replies
gotta add a
value
attribute to the radio buttons
you probably want value="1"
for the first one, value="2"
for the second, and so onOkay, done
Works! Thanks! 🙂
Need val…dangit @jochemm ! ::shakes fist in impotent rage::
Also, you can clean it up a bit:
Since
this
is the form that the event is being called on. And it's always good to remember to pass in the radix for parseInt
. If you don't want to use the radix then Number()
would work.What's radix btw?
radix is the base. Base 2 is binary, base 10 is decimal (what we normally use), base 16 is hexadecimal, etc.
Oh okay
In a positional numeral system, the radix or base is the number of unique digits, including the digit zero, used to represent numbers. For example, for the decimal/denary system (the most common system in use today) the radix (base number) is ten, because it uses the ten digits from 0 through 9.–https://en.wikipedia.org/wiki/Radix TIL vigesimal is base-20
Thanks! 🙂