Page 1 of 1
Javascript Autocalculate Field not working in form
Posted: Tue Oct 22, 2013 6:59 pm
by ojoc88
Hi All,
My Javascript autocalculate field (scroll to bottom) not working in my form ( look at here >www[dot]ptsp[dot]my/form/demo-order.html )
But it will work in standalone html file ( look at here > www[dot]ptsp[dot]my/form/testautocalculate.html )
Anybody know how to fix this?
Thanks
Regards,
ojoc88
Re: Javascript Autocalculate Field not working in form
Posted: Tue Oct 22, 2013 7:28 pm
by requinix
Uncaught ReferenceError: test is not defined
demo-order.html:178
Code: Select all
function calculate() {
var p1, p2, p3;
p1 = test.price1.value * 1; // 178
p2 = test.price2.value * 1;
p3 = test.price3.value * 1;
p4 = test.price4.value * 1;
p5 = test.price5.value * 1;
p6 = test.price6.value * 1;
p7 = test.price7.value * 1;
total_price = p1 + p2 + p3 + p4 + p5 + p6 + p7;
test.total_price.value = cent(Math.round(total_price*Math.pow(10,2))/Math.pow(10,2));
}
Re: Javascript Autocalculate Field not working in form
Posted: Tue Oct 22, 2013 9:30 pm
by ojoc88
requinix wrote:Uncaught ReferenceError: test is not defined
demo-order.html:178
Code: Select all
function calculate() {
var p1, p2, p3;
p1 = test.price1.value * 1; // 178
p2 = test.price2.value * 1;
p3 = test.price3.value * 1;
p4 = test.price4.value * 1;
p5 = test.price5.value * 1;
p6 = test.price6.value * 1;
p7 = test.price7.value * 1;
total_price = p1 + p2 + p3 + p4 + p5 + p6 + p7;
test.total_price.value = cent(Math.round(total_price*Math.pow(10,2))/Math.pow(10,2));
}
Sir , please advice me. i'm not good in java
Re: Javascript Autocalculate Field not working in form
Posted: Tue Oct 22, 2013 9:36 pm
by requinix
That's okay because Javascript isn't Java.
You tried to use the variable "test" but you didn't define it anywhere first. It was defined in the other page because it actually referred to the form (which was named "test") but you didn't do it that way in this page.
Re: Javascript Autocalculate Field not working in form
Posted: Tue Oct 22, 2013 10:47 pm
by ojoc88
requinix wrote:That's okay because Javascript isn't Java.
You tried to use the variable "test" but you didn't define it anywhere first. It was defined in the other page because it actually referred to the form (which was named "test") but you didn't do it that way in this page.
But sir , why this page working fine > www[dot]ptsp[dot]my/form/testautocalculate.html
i copy paste the same coding.
thanks
Re: Javascript Autocalculate Field not working in form
Posted: Tue Oct 22, 2013 10:57 pm
by requinix
Woah, that sounds like something really important I should have addressed in my reply.
Oh wait.
requinix wrote:It was defined in the other page because it actually referred to the form (which was named "test") but you didn't do it that way in this page.
Re: Javascript Autocalculate Field not working in form
Posted: Wed Oct 23, 2013 12:54 am
by ojoc88
requinix wrote:Woah, that sounds like something really important I should have addressed in my reply.
Oh wait.
requinix wrote:It was defined in the other page because it actually referred to the form (which was named "test") but you didn't do it that way in this page.
LOL .. sorry , my mistake . I should add " name="TEST" " in the " <form " code
thanks sir!
