Skip to main content
deleted 11 characters in body
Source Link
Kamil Kiełczewski
  • 93.6k
  • 34
  • 401
  • 375

Try this "template"html-approach" which is acceptable for small JS projects

function checkmsg(animal, inputis) {
  console.log(animal, inputis.checked);   // Do stuff
}
<input type="checkbox" oninput="checkoninput="msg('dog', this)" />Do you have a dog? <br>
<input type="checkbox" oninput="checkoninput="msg('frog',this)" />Do you have a frog?<br>
...

Try this "template-approach" which is acceptable for small JS projects

function check(animal, input) {
  console.log(animal, input.checked);
}
<input type="checkbox" oninput="check('dog', this)" />Do you have a dog? <br>
<input type="checkbox" oninput="check('frog',this)" />Do you have a frog?<br>
...

Try this "html-approach" which is acceptable for small JS projects

function msg(animal,is) {
  console.log(animal, is.checked);   // Do stuff
}
<input type="checkbox" oninput="msg('dog', this)" />Do you have a dog? <br>
<input type="checkbox" oninput="msg('frog',this)" />Do you have a frog?<br>
...

Source Link
Kamil Kiełczewski
  • 93.6k
  • 34
  • 401
  • 375

Try this "template-approach" which is acceptable for small JS projects

function check(animal, input) {
  console.log(animal, input.checked);
}
<input type="checkbox" oninput="check('dog', this)" />Do you have a dog? <br>
<input type="checkbox" oninput="check('frog',this)" />Do you have a frog?<br>
...