Skip to content
Advertisement

Is it possible with only PHP ? PHP FORM

I have a .csv file which contains the name of a product and its quantity separated by a comma. I would like to choose a product from the ComboBox and have its quantity displayed into ‘max’ of my input of numer type . Here is a sample of the .csv file :

JavaScript

Here is a sample of my HTML and PHP code :

JavaScript

Advertisement

Answer

No, because PHP is serverside only.. Have a read of What is the difference between client-side and server-side programming?

But is trivial to put it into json and use an onchange event on the select to then get the value from an object and then set into the quantity field.

Note, you should really always do PHP stuff first before output incase of any errors and because we are going to reuse $products more than once.

Example:

JavaScript

Working example: https://repl.it/@lcherone/BlueCreepyApplicationstack#index.php

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