Home > Software design >  How i can pass value vue to hidden textbox
How i can pass value vue to hidden textbox

Time:02-15

i need to pass value from vue to textbox, doing for one day but still didn't work.

my html input type code

<input type="hidden" id="variation" name="variation" v-model="variation">

second is my is my value is appear on paragraph

<p name fs="paragraph" fw="semi-bold" color="dark">{{ getVariantTitle(variant) }}</p>

its works for passing value to paragraph but not working for passing value into hidden html textbox. i really need value for passing into form post.

CodePudding user response:

As the input type is hidden, instead of v-model just try using v-bind:value, as you don't need two way binding for a hidden input

CodePudding user response:

I am sure there is better way to achieve what you're trying to do but for a quick fix you can try using v-bind instead of v-model

<input type="hidden" id="variation" name="variation" v-bind:value="variation">

This means the hidden text field will always have the same value as this.variation

EDIT:

<input type="hidden" id="variation" name="variation" :value="getVariantTitle(variant)">

  • Related