Answers for "how to get radio button value in javascript using class name"

3

turn off selinux centos

//This disables selinux this boot
$ setenforce 0

//To entirely disable selinux
$ sudo vi /etc/sysconfig/selinux

//Change the SELINUX=enforcing directive to SELINUX=disabled.

//Then reboot
Posted by: Guest on August-18-2020
0

centos selinux set permissive

sudo setenforce 0
Posted by: Guest on September-24-2020
14

jquery get value of radio input

$('input[name="name_of_your_radiobutton"]:checked').val();
Posted by: Guest on April-13-2020
11

get radio button value javascript

document.querySelector('input[name="rate"]:checked').value;
Posted by: Guest on May-17-2020
5

get value of checked radio button jquery

$('form input[type=radio]:checked').val();
Posted by: Guest on March-17-2020
0

how to get radio button value in javascript using class name

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Get Radio Button Value</title>
</head>
<body>
  <form>
    <label>
      <input type="radio" class="radio-option" name="option" value="Option 1"> Option 1
    </label>
    <label>
      <input type="radio" class="radio-option" name="option" value="Option 2"> Option 2
    </label>
    <label>
      <input type="radio" class="radio-option" name="option" value="Option 3"> Option 3
    </label>
    <button type="button" id="getValue">Get Selected Value</button>
  </form>
  <div id="result"></div>

  <script>
    document.getElementById('getValue').addEventListener('click', function () {
      const radioButtons = document.querySelectorAll('.radio-option');
      let selectedValue = null;

      radioButtons.forEach(radio => {
        if (radio.checked) {
          selectedValue = radio.value;
        }
      });

      document.getElementById('result').textContent = selectedValue 
        ? 'Selected Value: ' + selectedValue 
        : 'No option selected.';
    });
  </script>
</body>
</html>
Posted by: Ritik Raj on December-03-2024

Code answers related to "how to get radio button value in javascript using class name"

Code answers related to "Javascript"

Browse Popular Code Answers by Language