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:
rrrP粉7060387412024-03-27 13:14:36
This is one method. You can create a pair of data values for each input.
ssscccshow value of id {{ searchid ? searchid : "" }} here: {{ searchid === "1" ? id1data : searchid === "2" ? id2data : "none selected"}}
For brevity and organization, you can also use reactive()
purpose.
P粉1761515892024-03-27 10:50:14
If you insist on using ID, you can use the following method:
ssscccshow value of id {{ searchid ? searchid : "" }} here: {{ value ? value : "none selected"}}