In my form, there are a total of two text boxes with predefined values. However, I am looking for a way to retrieve the value of one specific textbox based on the entered ID number.
For example, if I input "1," I expect to see the value of text box 1 only.
https://i.sstatic.net/3K1xV.jpg
Currently, my implementation fetches data from both text boxes, which is not the desired outcome.
See below for the template:
<input v-model="textdata1" id="1" type="text" placeholder="i am id1, show my value">
<input v-model="textdata2" id="2" type="text" placeholder="i am id2, show my value">
<input v-model="searchid" type="text" placeholder="Specify the ID (1 or 2) you want to retrieve data for">
<button @click="getvalue">RECEIVE</button>
<div>The value of the specified ID will be shown here: {{id1data}}</div>
Implemented using VUEJS:
<script>
import { defineComponent, ref } from 'vue'
export default defineComponent({
setup() {
const id1data = ref("");
const id2data = ref("");
function getvalue(){
this.id1data = this.textdata1;
this.id2data = this.textdata2;
}
return {
id1data,
id2data,
getvalue,
}
}
})
</script>