Hello!
I have a page with a product catalog, where before adding a product to the cart, you can specify an arbitrary number of product units, but the maximum quantity of goods that can be added is loaded from the database using PHP at max = "":
<input type="text" value="1" min="1" max="<?=$product['nalichie']?>"> Further look, please, an example - here.
I want to do the following:
Write the maximum number of goods in the variable js, which can be added to the cart:
<script type="text/javascript">var nalichie ='<?=$product['nalichie']?';</script> It turns out this line js is displayed for each product, but with its own number. That is, I pass the value of PHP to JS.
Now my variable value is always the same, and not the product on which I clicked to add +1 product, for example. I alert(nalichie); this with alert(nalichie);
Why do I do such a check. After all, in fact, for the input field, and so the maximum number that a person can enter is given and all this is checked using js. But it is worth only in the developer panel to change the maximum number to an arbitrary number of its own, js will take a new value from max = "..." , and I would not want to.
I think this decision is useful to many. Can advise another way. I hope for your help :) I would be very grateful!