working on some word problems for my intro class and my html keeps getting stuck in a loop in the alert section of my code. once it goes in there it doesn't come back out no matter if I am inputting correctly. this is a beginner class so we have only just gotten into loops and switches so please keep it basic. thanks in advance!
var custOwed, numCust, dayTotal;
var woodTotal, alumTotal, steelTotal;
var rate;
var woodCount = 0;
var alumCount = 0;
var steelCount = 0;
var woodAccum = 0;
var alumAccum = 0;
var steelAccum = 0;
var anotherOrder = "yes";
var woodRate = 10;
var alumRate = 15;
var steelRate = 25;
var errorFlag = 0;
anotherOrder = prompt("Another Order", "yes or no");
while (anotherOrder == "yes") {
poleType = prompt("What type of pole would you like today?", "wood, aluminum, or steel");
numFeet = prompt("How many feet?", "10");
numFeet = parseInt(numFeet);
switch (poleType) {
case "wood":
woodCount = woodCount + 1;
woodAccum = woodAccum + numFeet;
rate = woodRate;
break;
case "aluminum":
alumCount = alumCount + 1;
alumAccum = alumAccum + numFeet;
rate = alumRate;
break;
case "steel":
steelCount = steelCount + 1;
steelAccum = steelAccum + numFeet;
rate = steelRate;
break;
default:
errorFlag = 1;
break;
}
if (errorFlag == 1) {
alert("You typed " + poleType + " the only choices were wood, aluminum, or steel");
anotherOrder = "yes";
} else {
custOwed = numFeet * rate;
alert("You Owe" + custOwed);
anotherOrder = prompt("Another Customer?", "yes or no");
}
}
numCust = woodCount + alumCount + steelCount;
woodTotal = woodAccum * woodRate;
alumTotal = alumAccum * alumRate
steelTotal = steelAccum * steelRate
dayTotal = woodTotal + alumTotal + steelTotal;
document.write("Number of Customers: " + numCust);
document.write("<br>Wood Customers: " + woodCount);
document.write("<br>Total Feet of Wood: " + woodAccum);
document.write("<br>Total owed of Wood: $" + woodTotal.toFixed(2));
document.write("<br>Aluminum Customers: " + alumCount);
document.write("<br>Total Feet of Aluminum: " + alumAccum);
document.write("<br>Total owed of Aluminum: $" + alumTotal.toFixed(2));
document.write("<br>Steel Customers: " + alumCount);
document.write("<br>Total Feet of Steel: " + alumAccum);
document.write("<br>Total owed of Steel: $" + alumTotal.toFixed(2));
document.write("<br>Total owed from the day: $" + dayTotal.toFixed(2));
Related
I'm using the following script to export Google Ads data from my account, but I am stuck with Google's pre-set date ranges and can't figure out how/if it's possible to jimmy these. Ideal date range would be year to date, with the report refreshing each day and adding on a fresh day's data, but would also be interested if we can get all time to work.
I'm a coding novice, so apologies in advance.
Script:
function main() {
var currentSetting = new Object();
currentSetting.ss = SPREADSHEET_URL;
// Read Settings Sheet
var settingsSheet = SpreadsheetApp.openByUrl(currentSetting.ss).getSheetByName(SETTINGS_SHEET_NAME);
var rows = settingsSheet.getDataRange();
var numRows = rows.getNumRows();
var numCols = rows.getNumColumns();
var values = rows.getValues();
var numSettingsRows = numRows - 1;
var sortString = "";
var filters = new Array();
for(var i = 0; i < numRows; i++) {
var row = values[i];
var settingName = row[0];
var settingOperator = row[1];
var settingValue = row[2];
var dataType = row[3];
debug(settingName + " " + settingOperator + " " + settingValue);
if(settingName.toLowerCase().indexOf("report type") != -1) {
var reportType = settingValue;
} else if(settingName.toLowerCase().indexOf("date range") != -1) {
var dateRange = settingValue;
} else if(settingName.toLowerCase().indexOf("sort order") != -1) {
var sortDirection = dataType || "DESC";
if(settingValue) var sortString = "ORDER BY " + settingValue + " " + sortDirection;
var sortColumnIndex = 1;
}else {
if(settingOperator && settingValue) {
if(dataType.toLowerCase().indexOf("long") != -1 || dataType.toLowerCase().indexOf("double") != -1 || dataType.toLowerCase().indexOf("money") != -1 || dataType.toLowerCase().indexOf("integer") != -1) {
var filter = settingName + " " + settingOperator + " " + settingValue;
} else {
if(settingValue.indexOf("'") != -1) {
var filter = settingName + " " + settingOperator + ' "' + settingValue + '"';
} else if(settingValue.indexOf("'") != -1) {
var filter = settingName + " " + settingOperator + " '" + settingValue + "'";
} else {
var filter = settingName + " " + settingOperator + " '" + settingValue + "'";
}
}
debug("filter: " + filter)
filters.push(filter);
}
}
}
// Process the report sheet and fill in the data
var reportSheet = SpreadsheetApp.openByUrl(currentSetting.ss).getSheetByName(REPORT_SHEET_NAME);
var rows = reportSheet.getDataRange();
var numRows = rows.getNumRows();
var numCols = rows.getNumColumns();
var values = rows.getValues();
var numSettingsRows = numRows - 1;
// Read Header Row and match names to settings
var headerNames = new Array();
var row = values[0];
for(var i = 0; i < numCols; i++) {
var value = row[i];
headerNames.push(value);
//debug(value);
}
if(reportType.toLowerCase().indexOf("performance") != -1) {
var dateString = ' DURING ' + dateRange;
} else {
var dateString = "";
}
if(filters.length) {
var query = 'SELECT ' + headerNames.join(",") + ' FROM ' + reportType + ' WHERE ' + filters.join(" AND ") + dateString + " " + sortString;
} else {
var query = 'SELECT ' + headerNames.join(",") + ' FROM ' + reportType + dateString + " " + sortString;
}
debug(query);
var report = AdWordsApp.report(query);
try {
report.exportToSheet(reportSheet);
var subject = "Your " + reportType + " for " + dateRange + " for " + AdWordsApp.currentAccount().getName() + " is ready";
var body = currentSetting.ss + "<br>You can now add this data to <a href='https://www.optmyzr.com'>Optmyzr</a> or another reporting system.";
MailApp.sendEmail(EMAIL_ADDRESSES, subject, body);
Logger.log("Your report is ready at " + currentSetting.ss);
Logger.log("You can include this in your scheduled Optmyzr reports or another reporting tool.");
} catch (e) {
debug("error: " + e);
}
}
function debug(text) {
if(DEBUG) Logger.log(text);
}
I've tried overwriting the data validation in the host spreadsheet, but think I need to amend the script itself also.
hy guys im learning google apps script to telegram bot,
i have write auto reply command and it success to reply, if i sent #02-02-2021 it will show all recorded data on that day, but on my code it just return only 1 row, i have trying anything but nothing work.
thanks for helping,
function searchDataByTanggalTransaksi(Tanggal){
var rangeNameTransaksi = "Transaksi!A2:O";
var rowsTransaksi = Sheets.Spreadsheets.Values.get(MYSSID, rangeNameTransaksi).values;
var panjangTransaksi = rowsTransaksi.length;
var Tanggal, Nama_Item, Divisi, Sat, Qty, Harga_Satuan, Debet, Kredit, Saldo, Peruntukan, Total = "";
var pesan ="";
for (var row = 0; row < panjangTransaksi; row++ ){
if ("#" + rowsTransaksi[row][1]==Tanggal){
Tanggal = "📅 Tanggal Transaksi : " + rowsTransaksi[row][1];
Nama_Item = rowsTransaksi[row][2];
Divisi = rowsTransaksi[row][3];
Sat = rowsTransaksi[row][4];
Qty = rowsTransaksi[row][5];
Harga_Satuan = rowsTransaksi[row][6];
Debet = rowsTransaksi[row][7];
Kredit = rowsTransaksi[row][8];
Saldo = rowsTransaksi[row][9];
Peruntukan = rowsTransaksi[row][12];
Total = "💸 Total Transaksi : " + rowsTransaksi[row][14] + ",-";
pesan += "<code>- " + Nama_Item + " |" + Qty + " " + Sat + " |" + Kredit + "</code>";
return pesan ;
}
}
return "Data tanggal tidak ditemukan";
}
function testgetRowsTransaksi(){
var tanggal = searchDataByTanggalTransaksi("#2");
var x = ""
}
One approach is to store found values in array, I assume that you want to return pesan right?
So solution one of possible solutions is that every record that is found you store it into array, and then return whole array(if nothing found array length will be 0).
Here is there modified code:
function searchDataByTanggalTransaksi(Tanggal) {
var rangeNameTransaksi = "Transaksi!A2:O";
var rowsTransaksi = Sheets.Spreadsheets.Values.get(MYSSID, rangeNameTransaksi)
.values;
var panjangTransaksi = rowsTransaksi.length;
var Tanggal,
Nama_Item,
Divisi,
Sat,
Qty,
Harga_Satuan,
Debet,
Kredit,
Saldo,
Peruntukan,
Total = "";
var pesan = "";
var resultArray = []; //Mentioned array to pass data in.
for (var row = 0; row < panjangTransaksi; row++) {
if ("#" + rowsTransaksi[row][1] == Tanggal) {
Tanggal = "📅 Tanggal Transaksi : " + rowsTransaksi[row][1];
Nama_Item = rowsTransaksi[row][2];
Divisi = rowsTransaksi[row][3];
Sat = rowsTransaksi[row][4];
Qty = rowsTransaksi[row][5];
Harga_Satuan = rowsTransaksi[row][6];
Debet = rowsTransaksi[row][7];
Kredit = rowsTransaksi[row][8];
Saldo = rowsTransaksi[row][9];
Peruntukan = rowsTransaksi[row][12];
Total = "💸 Total Transaksi : " + rowsTransaksi[row][14] + ",-";
pesan +=
"<code>- " +
Nama_Item +
" |" +
Qty +
" " +
Sat +
" |" +
Kredit +
"</code>";
return resultArray.push(pesan); //Data passed in per every iteration.
}
}
return resultArray; //returning line
return "Data tanggal tidak ditemukan"; // this line is obsolete
}
function testgetRowsTransaksi() {
var tanggal = searchDataByTanggalTransaksi("#2");
var x = "";
}
Though I'm not pretty sure, what kind of data panjangTransaksi variable holds, if you just want the all matching items in a concatenated string, you could try like below
function searchDataByTanggalTransaksi(Tanggal){
var rangeNameTransaksi = "Transaksi!A2:O";
var rowsTransaksi = Sheets.Spreadsheets.Values.get(MYSSID, rangeNameTransaksi).values;
var panjangTransaksi = rowsTransaksi.length;
return panjangTransaksi.reduce((acc, ele) => {
let Nama_Item, Divisi, Sat, Qty, Harga_Satuan, Debet, Kredit, Saldo, Peruntukan, Total = "";
if ("#" + ele[1] == Tanggal){
Tanggal = "📅 Tanggal Transaksi : " + ele[1];
Nama_Item = ele[2];
Divisi = ele[3];
Sat = ele[4];
Qty = ele[5];
Harga_Satuan = ele[6];
Debet = ele[7];
Kredit = ele[8];
Saldo = ele[9];
Peruntukan = ele[12];
Total = "💸 Total Transaksi : " + ele[14] + ",-";
acc += "<code>- " + Nama_Item + " |" + Qty + " " + Sat + " |" + Kredit + "</code>";
}
return acc;
}, '') || "Data tanggal tidak ditemukan";
}
The program will never enter this if ("#" + rowsTransaksi[row][1]==Tanggal) as Tanggal is undefined.
i have found the work around, on above method i was use return, but when i sendText it reply all the rows
case "/tgl" :
var ssIdLogistik ="mySsId";
var rangeNameTransaksi = "Transaksi!A2:O";
var rowsTransaksi = Sheets.Spreadsheets.Values.get(ssIdLogistik, rangeNameTransaksi).values;
var panjangTransaksi = rowsTransaksi.length;
var Tanggal, Nama_Item, Divisi, Sat, Qty, Harga_Satuan, Debet, Kredit, Saldo, Peruntukan, Total = "";
for ( var row = 0; row < panjangTransaksi; row++){
if (rowsTransaksi[row][1] == perintah[1]){
Tanggal = "📅 Tanggal Transaksi : " + rowsTransaksi[row][1];
Nama_Item = rowsTransaksi[row][2];
Divisi = rowsTransaksi[row][3];
Sat = rowsTransaksi[row][4];
Qty = rowsTransaksi[row][5];
Harga_Satuan = rowsTransaksi[row][6];
Debet = rowsTransaksi[row][7];
Kredit = rowsTransaksi[row][8];
Saldo = rowsTransaksi[row][9];
Peruntukan = rowsTransaksi[row][12];
Total = "💸 Total Transaksi : " + rowsTransaksi[row][14] + ",-";
text += "<code>- " + Nama_Item + " |" + Qty + " " + Sat + " |" + Kredit+ ",-" + "</code>\n";
}
}
if(text == ""){
text = "🚫 Periksa format penulisan kode permintaan Tanggal.\n\n" +
"Melihat transaksi berdasarkan tanggal di awali dengan '/tgl_' dengan format /tgl_hh-bb-tttt:\n" +
" 👉🏻 /tgl_02-02-2021 \n";}
sendText(updates.message.chat.id, logoData + "<code>" + Tanggal + "\n----------\n" + text + "----------\n" + Total + "</code>");
break;
So, i'm adding 2 characters 4 levels together (hp, attack, strength and defense) and then comparing them. However I am having a problem. when the numbers are added together they're added together as a string so it outputs as follows. 9060951/99709940 instead of 246 (90+60+95+1)/308 (99+70+99+40). Here is what I am doing.
function calculate(player1, player2) {
var total1 = player1.getTotal();
var total2 = player2.getTotal();
var differencePercentage;
if(total1 > total2) {
differencePercentage = total2 + "/" + total1 + " = " + (total2/total1);
} else {
differencePercentage = total1 + "/" + total2 + " = " + (total1/total2);
}
var percentage = differencePercentage;
return percentage;
}
function Player(hp, attack, strength, defense) {
this.hp = parseInt(hp);
this.attack = parseInt(attack);
this.strength = parseInt(strength);
this.defense = parseInt(defense);
this.getTotal = function() {
var total = 0;
total = hp + attack + strength + defense;
return total;
}
}
Why is this happening?
You are parsing the Ints into this.hp, this.attack etc. in your Player function but not into the getTotal function
Try this
this.getTotal = function() {
var total = 0;
total = this.hp + this.attack + this.strength + this.defense;
return total;
}
I can't figure this out I keep getting stuck in a loop. I don't know if I have my calculation or if statements in the right areas, please I could use some help. My output is like a end of day report. I could really use the help.
<script type="text/javascript">
<!--
// assignments
var cost, nachosCounter, moneyCollected, nachosRate, corndogRate, hotdogRate;
var hamAccum, hotdogAccum, corndogAccum, nachosAccum, hamburgerRate;
var beginDay, orderType, hamCounter, hotdogCounter, corndogCounter;
var totalHotdog, totalNachos, totalCorndog, totalHamburger, moneyCollected;
var hamburgerRate = 4;
var hotDogRate = 2;
var cornDogRate = 3;
var nachosRate = 5;
var hamCounter = 0;
var hotdogCounter = 0;
var corndogCounter = 0;
var nachosCounter = 0;
var beginDay = "yes"
//initalizing loop
beginDay = "yes"
//start loop
while (beginDay == "yes")
{
orderType = prompt("hamburger, hotdog, corndog, nachos", "");
if (orderType == "hamburger")
{
hamCounter = hamCounter + 1;
if (hamCounter == 1)
{
hamAccum = "<br>The total number of hamburgers purchased: " + hamCounter;
}
else
{
hamAccum = hamAccum + "<br>" + hamCounter;
}
}
else if (orderType == "hotdog")
{
hotdogCounter = hotdogCounter + 1;
if (hotdogCounter == 1)
{
hotdogAccum = "The total number of hotdog purchased:<br>" + hotdogCounter;
}
else
{
hotdogAccum = hotdogAccum + "<br>" + hotdogCounter;
}
}
if (orderType == "corndog")
{
corndogCounter = corndogCounter + 1;
if (corndogCounter == 1)
{
corndogAccum = "<br>The total number of corndogs purchased: <br>" + corndogCounter;
}
else
{
corndogAccum = corndogAccum + "<br>" + corndogCounter;
}
}
if (orderType == "nachos")
{
nachosCounter = nachosCounter + 1;
if (nachosCounter == 1)
{
nachosAccum = "<br>The total number of nachos purchased: <br>" + nachosCounter;
}
else
{
nachosAccum = nachosAccum + "<br>" + nachosCounter;
}
}
totalHotdog = hotdogCounter*hotDogRate;
totalHamburger = hamCounter*hamburgerRate;
totalCorndog = corndogCounter*cornDogRate;
totalNachos = nachosCounter*nachosRate;
moneyCollected = totalNachos+totalCorndog+totalHamburger+totalHotdog;
beginDay = prompt("More to add?", "yes");
}
//output
document.write(hotdogAccum);
document.write(hamAccum);
document.write(corndogAccum);
document.write(nachosAccum);
document.write("<br>The total dollar amount for hotdog: $ " + totalHotdog);
document.write("<br>The total dollar amount for hamburger: $ " + totalHamburger);
document.write("<br>The total dollar amount for corndogs: $" + totalCorndog);
document.write("<br>The total dollar amount for nachos: $" + totalNachos);
document.write("The total amount of money collected: $" + moneyCollected);
// -->
</script>
To preface this, we are a small organization and this system was built by someone long ago. I am a total novice at javascript so I have trouble doing complicated things, but I will do my best to understand your answers. But unfortunately redoing everything from scratch is not really an option at this point.
We have a system of collecting data where clients use a login to verify a member ID, which the system then uses to pull records from an MS Access database to .ASP/html forms so clients can update their data. One of these pages has the following function that runs on form submit to check that data in fields a/b/c sum to the same total as d/e/f/g/h/i. It does this separately for each column displayed (each column is a record in the database, each a/b/c/d/e/f is a field in the record.)
The problem is with this section of the function:
for (var j=0; j<recCnt; j++) {
sumByType = milesSurf[j] + milesElev[j] + milesUnder[j];
sumByTrack = milesSingle[j] + milesDouble[j] + milesTriple[j] + milesQuad[j] + milesPent[j] + milesSex[j];
etc.
It should use javascript FOR to loop through each record and test to see if they sum to the same thing.
In Firefox and IE this is working properly; the fields sum properly into "sumByType" and "sumByTrack". You can see below I added a little alert to figure out what was going wrong:
alert(sumByType + " " + j + " " + recCnt + " " + milesSurf[j] + " " + milesElev[j] + " " + milesUnder[j]);
In Chrome, that alert tells me that the components of "sumByType" and "sumByTrack" (the various "milesXXXXX" variables) are undefined.
My question is: Why in Chrome is this not working properly, when in IE and FFox it is? Any ideas?
Full function code below:
function submitCheck(formy, recCnt) {
//2/10/03: added milesQuad
//---------------checks Q#4 that Line Mileage by type is the same as by track
var milesElev = new Array();
var milesSurf = new Array();
var milesUnder = new Array();
var milesSingle = new Array();
var milesDouble = new Array();
var milesTriple = new Array();
var milesQuad = new Array();
var milesPent = new Array();
var milesSex = new Array();
var sumByType = 0;
var milesLineTrack = new Array(); //this is for Q5 to compare it to mileage by trackage
var j = 0; var sumByTrack = 0; var liney; var yrOp;
//var str = "document.frm.milesElev" + j;
//alert(str.value);
for (var i in document.frm) {
if (i.substring(0, i.length - 1) == "milesElev") {
milesElev[parseInt(i.substring(i.length-1, i.length))] = parseFloat(document.frm[i].value); }
if (i.substring(0, i.length - 1) == "milesSurf") {
milesSurf[parseInt(i.substring(i.length-1, i.length))] = parseFloat(document.frm[i].value); }
if (i.substring(0, i.length - 1) == "milesUnder") {
milesUnder[parseInt(i.substring(i.length-1, i.length))] = parseFloat(document.frm[i].value); }
if (i.substring(0, i.length - 1) == "milesSingle") {
milesSingle[parseInt(i.substring(i.length-1, i.length))] = parseFloat(document.frm[i].value); }
if (i.substring(0, i.length - 1) == "milesDouble") {
milesDouble[parseInt(i.substring(i.length-1, i.length))] = parseFloat(document.frm[i].value); }
if (i.substring(0, i.length - 1) == "milesTriple") {
milesTriple[parseInt(i.substring(i.length-1, i.length))] = parseFloat(document.frm[i].value); }
if (i.substring(0, i.length - 1) == "milesQuad") {
milesQuad[parseInt(i.substring(i.length-1, i.length))] = parseFloat(document.frm[i].value); }
if (i.substring(0, i.length - 1) == "milesPent") {
milesPent[parseInt(i.substring(i.length-1, i.length))] = parseFloat(document.frm[i].value); }
if (i.substring(0, i.length - 1) == "milesSex") {
milesSex[parseInt(i.substring(i.length-1, i.length))] = parseFloat(document.frm[i].value); }
if (i.substring(0, i.length -1) == "milesLineTrack") {
milesLineTrack[parseInt(i.substring(i.length-1, i.length))] = document.frm[i].value; } //12/13/02 used to be parseFloat(document.frm[i].value)
if (i.substring(0,5)=="Lines") {
liney = document.frm[i].value;
if (parseInt(liney)<1 || isNaN(liney)) {
alert("Each mode must have at least 1 line. Please correct the value in question #2.");
document.frm[i].select(); return false; }}
if (i.substring(0,8)=="yearOpen") {
yrOp = document.frm[i].value;
if (parseInt(yrOp)<1825 || isNaN(yrOp)) {
alert("Please enter a year after 1825 for question #3");
document.frm[i].select(); return false; }
}
}
for (var j=0; j<recCnt; j++) {
sumByType = milesSurf[j] + milesElev[j] + milesUnder[j];
sumByTrack = milesSingle[j] + milesDouble[j] + milesTriple[j] + milesQuad[j] + milesPent[j] + milesSex[j];
//---------------to round sumByTrack and sumByType from a long decimal to a single decimal place, like frm 7.89999998 to 7.9.
sumByTrack = sumByTrack * 10;
if (sumByTrack != parseInt(sumByTrack)) {
if (sumByTrack - parseInt(sumByTrack) >= .5) {
//round up
sumByTrack = parseInt(sumByTrack) + 1; }
else { //truncate
sumByTrack = parseInt(sumByTrack); }}
sumByTrack = sumByTrack / 10;
sumByType = sumByType * 10;
if (sumByType != parseInt(sumByType)) {
if (sumByType - parseInt(sumByType) >= .5) {
//round up
sumByType = parseInt(sumByType) + 1; }
else { //truncate
sumByType = parseInt(sumByType); }}
sumByType = sumByType / 10;
//-------------end of rounding ---------------------------
if (sumByType != sumByTrack) {
if (isNaN(sumByType)) {
sumByType = "(sum of 4.a., b., and c.) "; }
else {
sumByType = "of " + sumByType; }
if (isNaN(sumByTrack)) {
sumByTrack = "(sum of 4.d., e., f., g., h., and i.) "; }
else {
sumByTrack = "of " + sumByTrack; }
alert("For #4, the 'End-to-End Mileage By Type' " + sumByType + " must equal the 'End-to-end Mileage By Trackage' " + sumByTrack + ".");
alert(sumByType + " " + j + " " + recCnt + " " + milesSurf[j] + " " + milesElev[j] + " " + milesUnder[j]);
return false;
}
//alert (milesLineTrack[j] + " " + milesSingle[j] + " " + 2*milesDouble[j] + " " + 3*milesTriple[j] + " " + 4*milesQuad[j] + " " + 5*milesPent[j] + " " + 6*milesSex[j]);
var singDoubTrip = (milesSingle[j] + 2*milesDouble[j] + 3*milesTriple[j] + 4*milesQuad[j] + 5*milesPent[j] + 6*milesSex[j])
//----------round singDoubTrip to one digit after the decimal point (like from 6.000000001 to 6.0)
singDoubTrip = singDoubTrip * 10;
if (singDoubTrip != parseInt(singDoubTrip)) {
if (singDoubTrip - parseInt(singDoubTrip) >= .5) {
//round up
singDoubTrip = parseInt(singDoubTrip) + 1; }
else { //truncate
singDoubTrip = parseInt(singDoubTrip); }}
singDoubTrip = singDoubTrip / 10;
//----------end round singDoubTrip-----------------------------------------
if (parseFloat(milesLineTrack[j]) != singDoubTrip) {
//var mlt = milesLineTrack[j];
//if isNaN(milesLineTrack[j]) { mlt =
alert("For column #" + (j+1) + ", the mainline passenger track mileage of " + milesLineTrack[j] + " must equal the single track plus 2 times the double track plus 3 times the triple track plus 4 times the quadruple track plus 5 times the quintuple track plus 6 times the sextuple track, which is " + singDoubTrip + ".");
return false;
}
}
//---------------------end of checking Q#4----------------
//return false;
}
I think for (var i in document.frm) is the problem. You should not enumerate a form element, there will be plenty of unexpected properties - see Why is using "for...in" with array iteration a bad idea?, which is especially true for array-like objects. I can't believe this works properly in FF :-)
Use this:
var ele = document.frm.elements; // or even better document.getElementById("frm")
for (var i=0; i<ele.length; i++) {
// use ele[i] to access the element,
// and ele[i].name instead of i where you need the name
}
Also, you should favour a loop over those gazillion of if-statements.