javascript calculation

I'm trying to have javascript calculate an amount when the user inputs a number.

           <script type="text/JavaScript">
                function Calculate()
                     var TextBox2 = parseInt(document.getElementById('<%= numJazzPresident.ClientID%>').value);
                     var TextBox3 = parseInt(document.getElementById('<%= numWinePaint.ClientID%>').value);
                     var TextBox4 = parseInt(document.getElementById('<%= numVariety.ClientID%>').value);
                   if (TextBox2 == " ") {        var jazzDollar = 0;           }
                   else {                       jazzDollar = (parseInt(TextBox2) * 20);            }

                   if (TextBox3 == " ") {         var wineDollar = 0;             }
                   else {                        wineDollar = (parseInt(TextBox3) * 20);           }

                   if (TextBox4 == " ") {           var varietyDollar = 0;              }
                   else {                       varietyDollar = (parseInt(TextBox4) * 10);         }

                   document.getElementById('<%= TotalAmount.ClientID%>').value = alumniDollar + jazzDollar + wineDollar;
    }         </script>

html code

   <asp:TextBox ID="numJazzPresident"  onchange="return Calculate(this)"  runat="server" Width="32px" ></asp:TextBox>
the "totalAmount"   textbox never gets updated
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Where is alumniDollar defined?
document.getElementById('<%= TotalAmount.ClientID%>').value = alumniDollar + jazzDollar + wineDollar;

Open in new window

This is throwing an error which is why your text box is not being updated

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Russ SuterSenior Software DeveloperCommented:
There are a few things wrong with this code. You have undeclared variables and other variables that are declared but go out of scope before they are used in the final line of code.
Do the "empty" text boxes really contain a single space? Otherwise the comparison should be
if (TextBox4 == "") 

Open in new window

bcrooksAuthor Commented:
Thanks - its always the simple things
Julian HansenCommented:
You are welcome
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.