Join WhatsApp ChannelJoin Now

Vue JS Checked Radio Button Value On change Event

In this article, we will show you how to get selected radio button value using onchange event in vue js. This article will give you simple example of how to get selected radio button value using onchange event in vue js.

we can easily get selected text value of radio buttons in vue js. In this example, we will take a simple radio buttons with some options like laravel, php, codeigniter, etc. when you select it. we will get selected radio button text and value using on change event value vue js.

Example:-

<!DOCTYPE html>
<html>
<head>
    <title>Vue JS Checked Radio Button Value On change Event - codeplaners.com</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
    
<div id="app">
  
  <label><input type="radio" name="category_id" @change="onChange($event)" class="form-control" value="1"> Laravel</label>
  <label><input type="radio" name="category_id" @change="onChange($event)" class="form-control" value="2"> Codeigniter</label>
  <label><input type="radio" name="category_id" @change="onChange($event)" class="form-control" value="3"> Vue JS</label>
    
</div>
    
<script type="text/javascript">
    
    var app = new Vue({
      el: '#app',
      methods: {
          onChange(event) {
              var optionText = event.target.value;
              console.log(optionText);
          }
      }
    })
    
</script>
     
</body>
</html>

Recommended Posts