Javascript Calculations not working in IE8 and below Pleeeeease Help

Hi there,

Yes, this is what is happening. Here’s what I did in case it helps:

I downloaded Tectite FormMail from the following address: http://www.tectite.com/formmailpage.php
The download cosnsists of one PHP script ‘formmail.php’ and one sample form ‘sampleform.htm’
In formmail.php I changed line 256 to read:

$TARGET_EMAIL = array(EMAIL_NAME."@gmail\\.com$");

Then I copied and pasted the contents of post 36 (this here being post 41) into the HTML file.
In the line

<input type="hidden" name="recipients" value="..." />

I substituted the “…” for my gmail address.
I then uploaded both files to my web server, accessed the HTML form in my browser made a couple of changes so that ‘totalCost’ had a value other than zero and submitted it.

When I submit the form I am redirected to formmail.php (obviously) and I see the message:

Thanks! We've received your information and, if it's appropriate, we'll be in contact with you soon.
Your form submission was processed by FormMail (8.36), a PHP script available from www.tectite.com.

In the resulting email to my Gmail account I simply see the value of ‘totalCost’ when I submitted the form. In this case ‘180’.

You are obviously doing something differently somewhere, but this really works.
Therefore I would try and take this as a baseline, then keep adding pieces until you find out exactly where it breaks for you.

Halleluah… halleluah… I finally got the value show up in my email. Wow… I still don’t know exactly where the problem is, but I removed all the header lines and replaced it with what I had in my sample header and then it worked. So it seems that one of those additional fields might be causing the problem.

I will figure that out by adding one line at a time.

That was such a painful process. I thank you so much for sticking with this problem and helping me resolve it. You were a God-send. (Well I am actually working on setting up an online registration for a Church!).

Where can I show in this Form post that this is [Resolved] and where can I give you the highest rating for support and patience. Thank you so much.

Once I figure out the problem line, I will post it here if it is relevant for the readers.

Thank you.

Excellent! Well done!

AFAIK, there is actually no mechanism for marking a thread as solved and there is no “Thanks” mechanism, as the mods are worried that it will lead to people gaming the forum.
Nonetheless, thanks for asking.

Yes, do do that, as, as we discussed at the start of the thread, it might be helpful for others in the future.

Once again, I’m glad you got everything working!

All through this thread the code posted has included many calls to parseInt() which is a function for converting numbers from one bas to another where the way it is being used is to convert a string to a number - whiich is what the Number() function is for, You should replace all the parseInt() calls with Number() calls in order to avoid the string being misinterpreted as being in a number base other than 10 and so end up with a different value to what you expect - for example parseInt(‘011’) = 9 and not 11 when the leading zero means the number is interpreted as base 8 instead of base 10.

so instead of:

totalAdults = parseInt(adult.options[adult.selectedIndex].text);

you should use:

totalAdults = [B]Number[/B](adult.options[adult.selectedIndex].text);

or if you want something shorter you can use the following which also converts the string to a number:

totalAdults = [B]+[/B]adult.options[adult.selectedIndex].text;

If you are specifically using parseInt to discard a trailing non-numeric portion (such as dropping the dimensions off of 150px or 12in) then you need to specify the number base so that the parseInt doesn’t guess from the value:

totalAdults = parseInt(adult.options[adult.selectedIndex].text[B], 10[/B]);

Thanks for the message. I barely got it working now. So I will make that change rather cautiously in a test version first.
I wish I knew little bit more on Javascript to be able to pick up on these things. I am sure there are hundreds of sources out there, but wonder if there are any site that will teach you the script from basic up.

Okay I finally got it working on my actual page as well.

The culprit was a bunch of calls to an old TotalOrder() and CalculateTotal () that was in the <input> tag for all the entries. Silly mistakes partly to blame.
There were couple of other errors that got introduced as I tried the many things to get it working. One of the issues starting with an existing script and trying to glue on new code.
I am using Dreamweaver, but the html looks so cumbersome and misaligned even after using their code formatting. Then every time I paste the code to this forum and look at the preview, it looks soooo much more clean, aligned and formatted - easy to read. I am surprised why they can’t make the code viewer display the code little better!!!

Anyway, thanks again for your great support. Everytime I write another email, I was worried that you would say well you are on your on now pal!, but you didn’t and I will certainly reciprocate that to others when I have to help somebody else.

Take care.

Hi felgall,
Thanks a lot for pointing this out and also for the tip with the Unary + operator
I really appreciate it.