Order Form Won't Update

neoseeker191

I took over this website a little while back. The order form will only update the first three products, and that's only if I comment out the getTaxRate function. It doesn't update the Final Total either. I've made some attempt at getting it to work but ended up pulling my hair out. I'm not too familiar with javascript, but it seems like the code was written poorly. I would appreciate any help.

MrNobody

Best thing to do is to step through it with a script debugger. Firefox has a free one called Firebug. If you have any MS application development tools, then you probably have the MS Script Debugger for IE, too.

neoseeker191

Alright I ran the debugger and the iCnt value was always 3 no matter which product I chose. I found this odd, shouldn't it change? And why is it always 3?

MrNobody

iCnt is not an important variable -- it is only a loop counter. Since you have three products, the loop counter will always be 3 after the loop is complete.

neoseeker191

But I have more than 3 products, I have 10.

neoseeker191

But I don't have 3 products I have 10.

MrNobody

OK, then you need to step through it with the debugger and find out why the loop doesn't complete for all 10 of your products. If you want to post a live link to the page on your servers, then I can check it out in my browser with my debugger, too.

neoseeker191

I did, it's in my first post.

MrNobody

Well, you haven't been checking for your error messages in your browser. An error is generated every time you try to pick a quantity. This also means you didn't do a very good job of stepping through your code with the debugger -- because the debugger would have puked on this statement:

...and each one like it after that. This also explains why iCnt is always a 3 -- because that is where your script fails and that represents the field which does not exist in your page: QTY_4_TxTrayKT_DS. You actually have these:

PRICE_4_TxTrayHW_DS
QTY_4_TxTrayKW_DS
TOTAL_4_TxTrayKT_DS

neoseeker191

Well I've never used a browser debugger before, I'm not sure how to step through. How do you step through and why does it error out?

MrNobody

See updated post above.

neoseeker191

What a dumb mistake on my part, simple spelling errors. It works now thank you for your help. By the way how did you step through the javascript, I have firebug with Firefox.

MrNobody

I used Firebug, too.

Open Firebug

Set the Firebug Option to Break on All Errors

Refresh your page (to catch errors during page load)

Select a quantity

Firebug stops your script at the first error

neoseeker191

Okay I think I did that same thing when I was debugging, except I couldnt tell that it stopped on that statement you told me. How did you know that it was the error and that it was looking for a value that didn't exist?

MrNobody

See the attached image for an explanation using your page as the example.