Hi,
I have javascripts that display the number of radio stations from my xml files. I'm in need of a javascript that can add all the variables and then display the grand total. I looked on W3Schools's JS Math section and I couldn't find a section on addition.
Here's my individual scripts that display each state's # of stations:
etc...all the way to:
I just need a script that can take the "length" of all the variables (x1 through x50) and return the total # of stations from all 50 states.
I'm assuming it's something like this:
Thanks in advance!
I have javascripts that display the number of radio stations from my xml files. I'm in need of a javascript that can add all the variables and then display the grand total. I looked on W3Schools's JS Math section and I couldn't find a section on addition.
Here's my individual scripts that display each state's # of stations:
Code:
<script type="text/javascript"> xmlDoc=loadXMLDoc("stationsAK.xml"); x1=xmlDoc.getElementsByTagName('city'); document.write("Total Stations: " + x1.length); </script><br /> <script type="text/javascript"> xmlDoc=loadXMLDoc("stationsAL.xml"); x2=xmlDoc.getElementsByTagName('city'); document.write("Total Stations: " + x2.length); </script><br />
Code:
<script type="text/javascript"> xmlDoc=loadXMLDoc("stationsWY.xml"); x50=xmlDoc.getElementsByTagName('city'); document.write("Total Stations: " + x50.length); </script>
I'm assuming it's something like this:
Code:
<script type="text/javascript"> document.write(Math.sum(x1,x2,....,x50)) </script>
Comment