Well I know how to pass value of an item from drop down list to a text box, but this ones different. I'm very new to javascript and have no idea how to pass value calculated variable into a text box.
and then i need the value of the variable subtotal in a text box with id subtl
I think its wrong because it gives me NaN as the value for my text box subtl
And i dont know how to generalize a function. I have multiple variable "unit" (unit1, unit2, unit3... ), "qty" (qty1, qty2, qty3...) and aslo 'subtl" so I was wondering if there is a way to use 1 function for all of them?
Code:
function calct() { var un1=document.getElementById("unit").value; var qn1=document.getElementById("qty").value; var x1=eval(un1); var y1=eval(qn1); var z1=eval(x1*y1); document.getElementById("subtl").value= z1; }
I think its wrong because it gives me NaN as the value for my text box subtl
And i dont know how to generalize a function. I have multiple variable "unit" (unit1, unit2, unit3... ), "qty" (qty1, qty2, qty3...) and aslo 'subtl" so I was wondering if there is a way to use 1 function for all of them?
Comment