if no checkbox is selected make button inactive in javascript

You can achieve this by attaching an event listener to all checkboxes and updating the state of the button based on whether any checkboxes are checked or not. Here's an example:

HTML:

<input type="checkbox" id="checkbox1">
<input type="checkbox" id="checkbox2">
<button id="myButton" disabled>Click me</button>
127 chars
4 lines

JavaScript:

index.tsx
// get references to checkbox inputs and the button
const checkbox1 = document.getElementById('checkbox1');
const checkbox2 = document.getElementById('checkbox2');
const myButton = document.getElementById('myButton');

// attach event listeners to the checkboxes
checkbox1.addEventListener('click', updateButtonState);
checkbox2.addEventListener('click', updateButtonState);

// update button state based on checkboxes
function updateButtonState() {
  myButton.disabled = !checkbox1.checked && !checkbox2.checked;
}
516 chars
14 lines

In this example, we first grab references to the checkboxes and the button using the getElementById method. We then attach click event listeners to both checkboxes and define a function updateButtonState that sets the disabled attribute of the button based on whether the checkboxes are checked or not.

The updateButtonState function checks whether both checkboxes are unchecked using the ! (not) operator and sets the disabled attribute of the button accordingly.

gistlibby LogSnag