I would like to know how I can the data attribute of form select using Vue js. Here is the select
<form method="post">
<select @change="onChange" id="option" class="form-control
sectionprice" required="" name="option">
<option disabled="disabled" value="">Select Option</option>
<option data-type="Option" data-value="Mac Pro 128 GB" data-price="915.56">Mac Pro 128 GB</option><option data-type="Option" data-value="Mac Pro 254 GB" data-price="1300">Mac Pro 254 GB</option></select>
<input name="realprice" type="hidden" :value="dataprice"/>
</form>
<script>
var imagesection = new Vue({
el: '#pricesection',
data: {
dataprice:'';
},
methods:{
onChange(){
this.dataprice = this.dataset.price
},
}
})
</script>
What I am trying to achieve here is when an option is selected, using the @change, I can get the data-price of the selected option. Then the value of the hidden input field which is realprice will be updated with the data-price value.
Guys I will appreciate if someone help me out.