Skip to content
Advertisement

How to get the second value in the id to make onchange function?

I want to get the quantity value on change to show in the input, I make it data-cat_id='{$quantity}’ to show, but it cannot work.This value='{$id_book}’ is cannot change to ‘{$quantity}’, because id_book I want to use other place. Below is my coding:

JavaScript

Below is my output: output2

Hope someone can guide me how to show data-cat_id value in the input. Thanks.

Advertisement

Answer

I hope I understood correctly that you wish to set the dataset attribute cat_id associated with each option in the text input field when the user changes the dropdown selection?

JavaScript

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement