querySelectorAll indices, setAttribute

PHOTO EMBED

Fri Jun 02 2023 04:25:39 GMT+0000 (Coordinated Universal Time)

Saved by @thecowsays #javascript

function setExclusive() {
  const answers = document.querySelectorAll("input.answer");
  answers[0].setAttribute("type", "radio");
  answers[1].setAttribute("type", "radio");
  answers[2].setAttribute("type", "radio");
}
content_copyCOPY

There are 3 checkboxes allowing multiple choice -- this changes them to radio inputs to allow only one choice.