Caleb
Caleb

Reputation: 825

Javascript trouble

I am trying to make a calculator with Javascript, and I'm having a few problems... The code is at http://jsfiddle.net/NwkQW/10/.

  1. Try adding some values, and you'll see that the box that says TOTAL will change according to the values you enter. However, you'll also see that if you click CLEAR FORM, the value will not go back to TOTAL. How do I do that?
  2. I want to link to the javascript (e.g. <script type="text/javascript" src="mydomain.com/calculate.js></script>), but if I try, it doesn't work right! HELP!!!

Thanks!

Upvotes: 0

Views: 94

Answers (4)

Eric Mickelsen
Eric Mickelsen

Reputation: 10377

Just change your totalDiv to an input element and it will get cleared along with everything else. Or, don't rely on form reset and just clear everything in a method.

Upvotes: 0

FatherStorm
FatherStorm

Reputation: 7183

add a onClick to your clear form button like:

onClick="document.getElementById('totalDiv').innerHTML='';"

reset won't clear anything that's not a form element

see http://jsfiddle.net/NwkQW/16/

Upvotes: 1

Justin Thomas
Justin Thomas

Reputation: 5848

Add http://www. to the beginning of your source. You are trying to go to http://www.mydomain.com/mydomain.com/calculate.js assuming this file lives at /

Upvotes: 0

JClaspill
JClaspill

Reputation: 1745

<script type="text/javascript" src="http://www.mydomain.com/calculate.js"></script>

Upvotes: 1

Related Questions