Sorry, your whole idea on how to use/handle events is wrong. The parameters to the actual
GetTotalPrice
call comes from nowhere, they don't exist in the context of your call. I don't even want to think how you handle will execute when called like that. You can see it under the debugger, but there is no a big need to waste time on that as it will always fail.
First parameter which can really be passed to event handler is the event object, which has a reference to the event target. In your case, you don't need it, but this is certainly not the numeric value and not a DOM object:
https://developer.mozilla.org/en-US/docs/Web/Events/click[
^],
https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent[
^].
You don't even need it, so you can write an event handler without arguments. As to the arguments
txtqty
,
txtprice
,
txtTotalPrice
, you will have to pass it via the outer context. But you need to create a certain context for your event handler, so you would rather need to set up the event handler in code, not in the HTML element attribute:
var txteqty = document.getElementById("txteqty");
txteqty.onclick = function() {
var txtqty =
var txtprice =
var txtTotalPrice =
GetTotalPrice(txtqty, txtprice, txtTotalPrice);
}
If, for example, your three arguments come from other elements, you can calculate the string values using
document.getElementById("appropriateId").value
and then parse it to the number object, for example:
http://www.w3schools.com/jsref/jsref_parseint.asp[
^].
—SA