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
Javascript Autocalculate Field not working in form
Moderator: General Moderators
Javascript Autocalculate Field not working in form
Last edited by ojoc88 on Tue Oct 22, 2013 9:34 pm, edited 2 times in total.
Re: Javascript Autocalculate Field not working in form
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
Sir , please advice me. i'm not good in javarequinix wrote:Uncaught ReferenceError: test is not defined
demo-order.html:178Code: 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
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.
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
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
Woah, that sounds like something really important I should have addressed in my reply.
Oh wait.
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
LOL .. sorry , my mistake . I should add " name="TEST" " in the " <form " coderequinix 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.
thanks sir!