0

I'm trying to show the product quantity of a product depending on the product that was selected in the dropdown menu, however I can't figure out how to specifically get quantity from the lists.

Here is the select menu:

<select class="form-control" v-model="form.product_list">
  <option disabled value="">Select Product</option>
  <option v-for="product in products" :key="product.product_id" :value="product.product_id">{{product.product_name}}</option>
</select>

When you select a product from the select menu it binds it to form.product_list, after that I'm trying to show the product quantity instead of the product_id here: This does work however it shows the product_id instead of product quantity.

<td class="text-xs-left">
  <p>{{form.product_list}}</p>
</td>`

Here's the data:

data () {
  return {
    products: {},
    form: new Form({
      product_list: '',
    })
  }
}

I'm aware that changing :value="product.product_id" to :value="product.product_quantity" inside the select element will solve the issue, however I'm still going to need the product_id when I insert it into the database later on.

1 Answer 1

1

Change its value from product.product_id to product.product_qty. It will work hopefully


<option v-for="product in products" :key="product.product_id" :value="product.product_qty">{{product.product_name}}</option>
Sign up to request clarification or add additional context in comments.

2 Comments

I cannot do that as im gonna need the product.product_id when im gonna insert it in the database later on.
then make an onClick event, whenever someone click the product that onClick event will fire a method which assign product_qty value to a data variable. and return that data variable (containing qty ) to your view template.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.