VueJs Tutorials
- VueJs
- VueJs Instance
- Templates
- Component
- Computed Properties
- Watch Property
- Binding
- Events
- Rendering
- Directives
- Mixins
- Reactive Interface
- String Length
- Onchange Events
- Ternery Operator
- Global variable
- Get data attribute value
- String to array
- How to Get Array Length
- call a function on Page load
- current Date and Time
- Replace String
- Open link on new tab
- setTimeout in Vue JS
- object or array empty or not
- get element by id
- Laravel Vue Flash Message
How to get radio button value on onchange events?
File name : index.php
<!DOCTYPE html>
<html>
<head>
<title>How to Get Radio Button Value on Onchange Event </title>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
<div id="radioapp">
<label><input type="radio" name="language" @change="onChange($event)" class="form-control" value="laravel"> Laravel</label>
<label><input type="radio" name="language" @change="onChange($event)" class="form-control" value="codeigniter"> Codeigniter</label>
<label><input type="radio" name="language" @change="onChange($event)" class="form-control" value="php"> PHP</label>
</div>
<script type="text/javascript">
var app = new Vue({
el: '#radioapp',
methods: {
onChange(event) {
var objval = event.target.value;
console.log(objval);
alert(objval);
}
}
})
</script>
</body>
</html>
How to Get Selected Option Text and value.
File name : index.php
<!DOCTYPE html>
<html>
<head>
<title>How to Get Selected Option Text and value.</title>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
<div id="appid">
<select name="language_id" @change="onChange($event)" class="form-control">
<option>--- Select Category ---</option>
<option value="1">PHP</option>
<option value="2">java</option>
<option value="3">Laravel</option>
<option value="4">CI</option>
<option value="5">Vue JS</option>
</select>
</div>
<script type="text/javascript">
var app = new Vue({
el: '#appid',
methods: {
onChange(event) {
var optionValue = event.target.value;
var optionText = event.target.options[event.target.options.selectedIndex].text;
console.log(optionText);
console.log(optionValue);
}
}
})
</script>
</body>
</html>
File name : index.php
File name : index.php