I have two text boxes
, both text boxes have values.
But I want to get the value of a text box based on the id number I want to enter.
If I enter 1 it should show the value of textbox 1.
This is what I tried and now it shows the data in both text boxes.
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="which ids data you want, 1 or 2 "> <button @click="getvalue">RECEIVE</button> <div>show value of id 1or2 here: {{id1data}}</div>
VUEJS:
rrr
This is one method. You can create a pair of data values for each input.
For brevity and organization, you can also use
reactive()
purpose.If you insist on using ID, you can use the following method: