Ver Mensaje Individual
  #2 (permalink)  
Antiguo 12/04/2016, 03:35
Avatar de Eleazan
Eleazan
 
Fecha de Ingreso: abril-2008
Ubicación: Ibiza
Mensajes: 1.879
Antigüedad: 16 años
Puntos: 326
Respuesta: Javascript tomando un ID de PHP

Buenas,

A la hora de llamar a la función js, te falta un parámetro...

Por ejemplo:
Código PHP:
echo "<input type='text' onkeyup='multiplic(\'".$id_product."\')' name='quantity' id='quantity".$id_product."' value='0' class='qty' size='10px'/>"
Con eso, deberías recibir el id en id_product en tu función JS, y ponerla dinámica:

Código Javascript:
Ver original
  1. function multiplic(id_product)
  2.  {
  3. console.log("Id del producto: " + id_product);
  4.  var total = 0;
  5.  var valor1 = document.getElementById("quantity"+id_product).value;
  6.  var valor2 = document.getElementById("order_price"+id_product).value;
  7.  
  8.  total = (valor1 * valor2);
  9.  
  10.  var Display = document.getElementById("Display"+id_product);
  11.  Display.innerHTML = total;
  12.  }
__________________
>> Eleazan's Source
>> @Eleazan