473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Javascript calculation in oscommerce page

Hello,
What am I doing wrong ? this code doesn't work in a oscommerce site. Please help me have a look and tell me the problem.
The code:
Expand|Select|Wrap|Line Numbers
  1. <SCRIPT TYPE="text/javascript">
  2.  
  3. function battery_size()
  4. {
  5. //shove values into variables
  6. var SystemSize = document.forms[0].SystemSize.value;
  7.  
  8. var voltselect = document.forms[0].SYSVOLT.selectedIndex;
  9. var SYSVOLT = document.forms[0].SYSVOLT.options[voltselect].value;
  10.  
  11. var dayselect = document.forms[0].CloudyDays.selectedIndex;
  12. var CloudyDays = document.forms[0].CloudyDays.options[dayselect].value;
  13.  
  14. var limitselect = document.forms[0].DischargeLimit.selectedIndex;
  15. var DischargeLimit = document.forms[0].DischargeLimit.options[limitselect].value;
  16.  
  17. var TempMulti = document.forms[0].TempMulti.value;
  18.  
  19. //calculate result 
  20. var result =(((SystemSize/SYSVOLT)*CloudyDays)/(DischargeLimit*0.01))*TempMulti;
  21. result = Math.round(result);
  22.  
  23. //validate
  24.  
  25. var verify = isNaN(result);
  26. if (verify) {
  27.     alert ("Energy Consumption must be a number");
  28.     document.forms[0].SystemSize.focus();
  29.     return false;
  30.     };
  31.  
  32. // write result to form
  33. document.forms[0].result.value = result;
  34. }
  35. </SCRIPT>
  36.  
The related form
[HTML] <FORM>
<table width="100%" border="0" cellspacing="4" cellpadding="0">
<tr>
<td colspan="2"><font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><br />How much storage you would like your battery bank to provide? Base this on the number of days your system will have to provide power without solar input. How many cloudy days in a row are typical for your location? Do you have an alternate source of power—grid intertie or generator—during these days? </font><br />
<br />
<font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">It is not good for batteries to be completely drained (ever), nor is it good for them to be consistently undercharged. It is best to size your battery bank so that it gets regularly charged to capacity.
<br />

<font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">When you sized your solar panel array, you were dealing with watts per hour that you need to produce. Now you will be dealing with amps per hour that you need to store. Remember watts = volts X amps. </font></p>
</td>
</tr>
<tr>
<td><font size="2" color="#dd0000" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><span class="Titleblack">1. Enter your System Size</span></font><font color="#dd0000" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><span class="Titleblack"><br />
</span></font><font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">This is the value obtained in step1. Put the number here <br />
<br />
</font></td>
<td width="154"><font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><input name="SystemSize" value=" " maxlength="10" size="5" /> <span class="Titleblack">Watts</span></font></td>
</tr>
<tr>
<td><font size="2" color="#dd0000" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><span class="Titleblack">2. Enter your system Voltage</span></font><font color="#dd0000" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><span class="Titleblack"><br />
</span></font><font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"> Choose your system voltage <br />
<br />
</font></td>
<td width="154"><font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><SELECT NAME="SYSVOLT">

<OPTION VALUE="12">12</OPTION>
<OPTION SELECTED VALUE="24">24</OPTION>
<OPTION VALUE="48">48</OPTION>
</SELECT> <span class="Titleblack">Volt</span></font></td>
</tr>
<tr>
<td><font size="2" color="#dd0000" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><span class="Titleblack">3.Enter the maximum number of consecutive cloudy weather days expected in your area </span></font><font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><span class="Titleblack"> </span></font><font face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><span class="boxText"><font size="2">This is the number of days of autonomy you would like your system to support(Generally 3~5days).</font></span></font><font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><span class="boxText"><br />
<br />
</span></font></td>
<td width="154"><font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><SELECT NAME="CloudyDays">
<OPTION VALUE="1">1</OPTION>

<OPTION VALUE="2">2</OPTION>
<OPTION SELECTED VALUE="3">3</OPTION>
<OPTION VALUE="4">4</OPTION>
<OPTION VALUE="5">5</OPTION>
<OPTION VALUE="6">6</OPTION>
<OPTION VALUE="7">7</OPTION>
</SELECT> <span class="Titleblack">Days</span></font></td>
</tr>
<tr>
<td><font size="2" color="#dd0000" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><span class="Titleblack">4. Enter the discharge limit for the batteries</span></font><font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><span class="Titleblack"> </span></font><font face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><span class="boxText"><font size="2">The depth of discharge for the battery you have chosen. This provides a safety factor so that you can avoid over-discharging your battery bank.<br />Between 0.2 ~0.8 , an acceptable discharge average is 50% or 0.5 discharge limit</font> </span></font><font size="2" color="#dd0000" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><span class="boxText"><br />
</span></font><br/> </td>
<td width="154"><font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><SELECT NAME="DischargeLimit">
<OPTION VALUE="1">20</OPTION>

<OPTION VALUE="2">30</OPTION>
<OPTION VALUE="3">40</OPTION>
<OPTION SELECTED VALUE="4">50</OPTION>
<OPTION VALUE="5">60</OPTION>
<OPTION VALUE="6">70</OPTION>
<OPTION VALUE="7">80</OPTION>
</SELECT> <span class="Titleblack">% </span></font></td>
</tr>
<tr>
<td><font size="2" color="#dd0000" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><span class="Titleblack">5. Select the closest multiplier
below for the average ambient winter temperature your batteries
will experience.</span></font><font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><span class="Titleblack"> </span></font><font face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><span class="boxText"><font size="2"> Enter the multiplier here.</font> </span></font><font size="2" color="#dd0000" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><span class="boxText"><br /></span></font><br/></td>
<td width="154"><font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><input type="text" name="TempMulti" size="5" /> </font></td>
</tr>
<tr> <td>
<table width="180" align="center" border="1" cellspacing="2" cellpadding="0" bgcolor="#dddddd">
<tr>
<td colspan="3"><font size="1" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">Ambient Temperature Multiplier</font></td>
</tr>
<tr>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">80F</font></td>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">26.7C</font></td>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">1.00</font></td>
</tr>
<tr>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">70F</font></td>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">21.2C</font></td>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">1.04</font></td>
</tr>
<tr>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">60F</font></td>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">15.6C</font></td>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">1.11</font></td>
</tr>
<tr>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">50F</font></td>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">10.0C</font></td>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">1.19</font></td>
</tr>
<tr>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">40F</font></td>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">4.4C</font></td>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">1.30</font></td>
</tr>
<tr>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">30F</font></td>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">-1.1C</font></td>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">1.40</font></td>
</tr>
<tr>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">20F</font></td>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">-6.7C</font></td>
<td><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">1.59</font></td>
</tr></table> </td></tr>
<tr>
<td colspan="2">
<div align="center">
<font size="2"><INPUT NAME="calc" VALUE=" Calculate " TYPE=BUTTON
onClick=battery_size(this.form)></font></div>
</td>
</tr>
<tr>
<td>
<div align="right">
<font size="2" color="#ff0033" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><strong>Total Batteries Capacity Needed:</strong> </font><font color="#ff0033"><strong> </strong></font></div>
</td>
<td width="154"><font size="2"><INPUT NAME="result" READONLY SIZE="8" maxlength="8"> </font><font size="2" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">Amps/Hour</font></td>
</tr>

</table>
</FORM>[/HTML]
Oct 6 '07 #1
1 1261
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

When you say it doesn't work, what do you expect it to do instead and what does it do instead? Do you get any errors? If so, what are they?

Please use code tags when posting code, e.g.
[CODE=javascript]
JavaScript code here..
[/code]
Oct 6 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Chris Hope | last post by:
Anyone know of any decent PHP/MySQL OSS ecommerce packages other than osCommerce and ZenCart? From what I've seen of ZenCart it just appears to be a fork of osCommerce and having now set a site up...
2
by: Angie | last post by:
Hello everybody, I have an osCommerce shopping cart on my site, which is an open-source product that uses php. I'm very new to php. I also have an online scheduling application that I outsourced...
13
by: Matthew Crouch | last post by:
Okay, I've fiddled with this and I'm not passing judgment. If this application is great and there's just something I don't know, I'd love to learn. Item: Customizations (other than simple...
53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
6
by: Steven Kalcevich | last post by:
Hi all. I am working on finishing an oscommerce based site and need some help. One page is listing in 1 column 6 down, I wish to have a layout of 4 across and 5 down. When there is more then 20...
4
by: opensourcearts | last post by:
Hello all, I am working on an application that is basically a bridge between oscommerce and gallery2 software, with some other functionality. It will allow users to port all of their media...
0
by: Kshipra | last post by:
In this era of growing Internet usage, e-commerce has started to grab a big share of the market. The title helps the readers understand how they can earn their share of money from the growing...
4
by: Bala | last post by:
Hi Experts, How to resolve this osCommerce issues? for the past couple of days, its irritating me like anything. well as i run on my local pc it works fine. my local pc configuration is ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.