I'm brand new to javascript and am trying to round out my web developer skills but after a week and a half of research on this, I'm now up against the wall for a solution.
The client will updating any water fee changes and will not have access to ftp. I should add this is a Joomla! site.
Any ideas would greatly appreciated. Also, if anyone knows of an extensive online javascript library so I can keep learning, that would great also. Cheers.
My code:
Expand|Select|Wrap|Line Numbers
- <form name="water_calc" form action="" method="POST"><label>Enter number of gallons of water: </label>
- <input type="text" size="7" name="numGal" title="numGal" />
- <span id="calc1"></span>
- <input type="hidden" name="rate" title="Water Rate" value="2.61" />
- <input type="hidden" name="sewRate" title="Sewer Rate" value="3.05" />
- <label type="text" name="calc1" title="Total Fee"></label>
- <input type="button" id="calculate" name="calculate" value="Calculate" />
- <input type="reset" onclick="document.water_calc.reset()" value="Clear" name="Clear" title="Clear" /></form>
Expand|Select|Wrap|Line Numbers
- <script type="text/javascript">
- var btn = document.getElementById('calculate');
- btn.onclick = function() {
- var numGal = parseInt(document.getElementById('numGal').value);
- var rate = parseInt(document.getElementById('rate').value);
- var sewRate = parseInt(document.getElementById('sewRate').value);
- var calc1 = document.getElementById('calc1');
- calc1.value = numGal * (rate + sewRate) / 1000;
- var msg = [];
- if (isNaN(val1)) {
- msg.push('This is not a number');
- }
- if (msg.length > 0) {
- calc1.innerHTML = msg.join(', ');
- } else {
- calc1.innerHTML = 'X x (Y + Z)/ 1000 = ' numGal * (rate * sewRate) / 1000;
- }
- };
- </script>