Array solution unit price: & lt; input & nbsp; typetext & nbsp; size6 & nbsp; namedanjia [] & nbsp; onblurfx () & gt; quantity: & lt; input & nbsp; typetext & nbsp; size6 & nbsp; name array solution
Unit Price: 10 thousand
Quantity:
Total price: RMB
Script
Function fx (){
Var s = document. getElementById ('danjia [] '). value;
If (! S) return;
S = parseInt (s );
Var c = document. getElementById ('shuliang [] '). value;
C = parseInt (c );
If (! C) return;
Document. getElementById ('zongjia '). innerHTML = Math. round (s * c)
}
Script
How can I put the total price in the corresponding total price td?
------ Solution --------------------
Var s = document. getElementById ('danjia [] '). value;
Should be
Var s = document. getElementById ('danjia '). value;
Var c = document. getElementById ('shuliang [] '). value;
Should be
Var c = document. getElementById ('shuliang '). value;
------ Solution --------------------
You use getElementById (); the attribute id should be written in the brackets, rather than the getElementsByName ();
------ Solution --------------------
Reference:
The two upstairs helped me solve the problem, but how to calculate the total? That is to say, all total prices and values. Solving,
The landlord does not like jquery very much.
If you like it, you can write var zj like this;
Zj = $ ('# danjia'). val () * $ ('# shuliang'). val ();
$ ('# Zongjia'). text (zj );
Hope the answer is helpful to you