문제

I'm trying to get the input for a radio button group but I can't find anywhere any examples or explanations of how to. All the ones I end up finding is deprecated or does not work :(

What I wan't is this:

The form will have 4 radio button groups and when submit is pressed I wan't to get the information from those 4 groups then do something with it. But I can't find anywhere a good way of doing it :(

도움이 되었습니까?

해결책

Tried it and works

<input type="radio" id="r1" name="rate" value="Fixed Rate"> Fixed Rate
<input type="radio" id="r2" name="rate" value="Variable Rate"> Variable Rate
<input type="radio" id="r3" name="rate" value="Multi Rate" checked="checked">

.

main () {
  querySelectorAll('input[name=rate]').onClick.listen(clickHandler);
}

void clickHandler(MouseEvent e) {
  // two different ways of accessing the current value
  print('target: ${(e.target as InputElement).value}');
  print('checked: ${(querySelector('input[name=rate]:checked') as InputElement).value}');
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top