0

This is my code where I pass value:

echo '<td style="width:10px;" ><input type="text" name="qty__'.$product_name.'" id="qty__'.$product_name.'"  onkeyup="total_amounts(this,'.$product_name.');"  /></td>';

i just only want onkeyup function take this and also product name which will be used in below code

<script>
   function total_amounts(qty,product_id)
 {   
 alert('hi');
var product_id = document.getElementById("discount1").value;

   alert(product_id);
 var price1 = document.getElementById("price1__"+product_id).value;
  var discount1 = document.getElementById("discount1__"+product_id).value;
 alert(discount1);

    document.getElementById('net_price').value = price1;

    }
  </script>

but the problem is I have not received the product name inside the script.

3
  • Is the DOM rendered like you have expected? Commented Aug 15, 2016 at 14:49
  • Why do you pass this without using it? Commented Aug 15, 2016 at 14:50
  • i just want product quantity with name inside function Commented Aug 15, 2016 at 14:53

1 Answer 1

1

Maybe you are forgetting to put strings in quotes?

Escaping ' by using a backslash \' allows you to do this.

onkeyup="total_amounts(this,\''.$product_name.'\');"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.