Skip to content
Advertisement

how to show value from hidden box when button onclick in php loop

i trying to build shop simple site for learning but i got stuck when i click button. when i click it nothing happen. it should showing text from value on hidden button when i click button.

below is my php code

JavaScript

the result is multiple button appear but nothing happen when i click button. total button is based from database how many data have.

below is my jsquery

JavaScript

value from id(price) that i want show on div id(sendPrice), value from id(id) that i need to show in href button, value from id(quantity) that i need it will appear on div id(showQuantity) when button is onclick.

below is html code

JavaScript

Advertisement

Answer

First add {$i} to your onclick='myFunction()' like onclick='myFunction({$i})'

second in your javascript remove the for loop and add i to function myFunction() { like function myFunction(i) {

Demo

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