I have a form that calculates and fills in the fields for subtotals, tax, and totals after the user enters an amount for a product, using onchange.
The code works fine so far in all other browsers except Netscape 6.0. In this browser, it just blanks out the fields that are automatically updated. If I hit the reload button then it shows the correct values. So seeing that I decided to test for Netscape and 5 and if it was that browser, do location.reload(true);. Well it reloaded but the form reflects as if it were reset.
But then when I manually click on the Reload button in the browser, it shows the correct results. Does anyone know what's going on with this? Is there something I did wrong when I assigned values in my code?
thanks
Here is my code in it's entirety:
function changeform(ssform)
{
var subtotalVal;
subtotalVal = 0;
var taxVal;
taxVal = 0;
var totalVal;
totalVal = 0;
var strSubtotalVal;
var strTaxVal;
var strTotalVal;
var SYC6FTtempVal;
SYC6FTtempVal = document.surestopform["SYC6FT"].value;
var SYC6FCtempVal;
SYC6FCtempVal = document.surestopform["SYC6FC"].value;
var SYC1FF2tempVal;
SYC1FF2tempVal = document.surestopform["SYC1FF2"].value;
var SYC7TA1tempVal;
SYC7TA1tempVal = document.surestopform["SYC7TA1"].value;
var SYC8T2tempVal;
SYC8T2tempVal = document.surestopform["SYC8T2"].value;
var SYC8TAC2tempVal;
SYC8TAC2tempVal = document.surestopform["SYC8TAC2"].value;
var SYC650BBtempVal;
SYC650BBtempVal = document.surestopform["SYC650BB"].value;
if ((SYC6FTtempVal == "" || (SYC6FTtempVal == " " || (SYC6FTtempVal == " " )|| (SYC6FTtempVal == " ")
{
SYC6FTtempVal = 0;
}
else
{
if (isNaN(SYC6FTtempVal))
SYC6FTtempVal = 0;
else
SYC6FTtempVal = document.surestopform["SYC6FT"].value;
}
if ((SYC6FCtempVal == "" || (SYC6FCtempVal == " " || (SYC6FCtempVal == " " )|| (SYC6FCtempVal == " ")
{
SYC6FCtempVal = 0;
}
else
{
if (isNaN(SYC6FCtempVal))
SYC6FCtempVal = 0;
else
SYC6FCtempVal = document.surestopform["SYC6FC"].value;
}
if ((SYC1FF2tempVal == "" || (SYC1FF2tempVal == " " || (SYC1FF2tempVal == " " )|| (SYC1FF2tempVal == " ")
{
SYC1FF2tempVal = 0;
}
else
{
if (isNaN(SYC1FF2tempVal))
SYC1FF2tempVal = 0;
else
SYC1FF2tempVal = document.surestopform["SYC1FF2"].value;
}
if ((SYC7TA1tempVal == "" || (SYC7TA1tempVal == " " || (SYC7TA1tempVal == " " )|| (SYC7TA1tempVal == " ")
{
SYC7TA1tempVal = 0;
}
else
{
if (isNaN(SYC7TA1tempVal))
SYC7TA1tempVal = 0;
else
SYC7TA1tempVal = document.surestopform["SYC7TA1"].value;
}
if ((SYC8T2tempVal == "" || (SYC8T2tempVal == " " || (SYC8T2tempVal == " " )|| (SYC8T2tempVal == " ")
{
SYC8T2tempVal = 0;
}
else
{
if (isNaN(SYC8T2tempVal))
SYC8T2tempVal = 0;
else
SYC8T2tempVal = document.surestopform["SYC8T2"].value;
}
if ((SYC8TAC2tempVal == "" || (SYC8TAC2tempVal == " " || (SYC8TAC2tempVal == " " )|| (SYC8TAC2tempVal == " ")
{
SYC8TAC2tempVal = 0;
}
else
{
if (isNaN(SYC8TAC2tempVal))
SYC8TAC2tempVal = 0;
else
SYC8TAC2tempVal = document.surestopform["SYC8TAC2"].value;
}
if ((SYC650BBtempVal == "" || (SYC650BBtempVal == " " || (SYC650BBtempVal == " " )|| (SYC650BBtempVal == " ")
{
SYC650BBtempVal = 0;
}
else
{
if (isNaN(SYC650BBtempVal))
SYC650BBtempVal = 0;
else
SYC650BBtempVal = document.surestopform["SYC650BB"].value;
}
//alert (SYC6FTtempVal);
//alert(document.surestopform["SYC6FT"].value);
document.surestopform["SYC6FTval"].value = SYC6FTtempVal;
document.surestopform["SYC6FCval"].value = SYC6FCtempVal;
document.surestopform["SYC1FF2val"].value = SYC1FF2tempVal;
document.surestopform["SYC7TA1val"].value = SYC7TA1tempVal;
document.surestopform["SYC8T2val"].value = SYC8T2tempVal;
document.surestopform["SYC8TAC2val"].value = SYC8TAC2tempVal;
document.surestopform["SYC650BBval"].value = SYC650BBtempVal;
subtotalVal = (SYC6FTtempVal * 24.95) + (SYC6FCtempVal * 24.95) + (SYC1FF2tempVal * 21.95) + (SYC7TA1tempVal * 29.95) + (SYC8T2tempVal * 39.95) + (SYC8TAC2tempVal * 49.95) + (SYC650BBtempVal * 99.95);
//alert(subtotalVal);
subtotalVal = Math.round(subtotalVal *100)/100;
taxVal = Math.round((subtotalVal * .055)*100)/100;
totalVal = Math.round((subtotalVal + taxVal)*100)/100;
strSubtotalVal = subtotalVal + "";
strTaxVal = taxVal + "";
strTotalVal = totalVal + "";
document.surestopform["subtotal"].value = formatNum(strSubtotalVal);
document.surestopform["tax"].value = formatNum(strTaxVal);
document.surestopform["total"].value = formatNum(strTotalVal); // Math.round(totalVal*100)/100;
var brows = navigator.appName;
alert(brows);
var browsvers = navigator.appVersion;
//alert(browsvers.charAt(0));
if((navigator.appName == "Netscape" && (browsvers.charAt(0) == 5))
{
alert("it's netscape"
location.reload(true);
//document.window.reload();
}
//{ alert(browsvers.charAt(0)); }
//
}
function formatNum(tempVal)
{
var newVal;
var aft;
if(tempVal.indexOf("." == -1)
{
newVal = tempVal + ".00";
return newVal;
}
else
{
aft = tempVal.substring(tempVal.indexOf(".",tempVal.length);
if(aft.length == 2)
{
newVal = tempVal + "0";
return newVal;
}
else
{ return tempVal; }
}
}
The code works fine so far in all other browsers except Netscape 6.0. In this browser, it just blanks out the fields that are automatically updated. If I hit the reload button then it shows the correct values. So seeing that I decided to test for Netscape and 5 and if it was that browser, do location.reload(true);. Well it reloaded but the form reflects as if it were reset.
But then when I manually click on the Reload button in the browser, it shows the correct results. Does anyone know what's going on with this? Is there something I did wrong when I assigned values in my code?
thanks
Here is my code in it's entirety:
function changeform(ssform)
{
var subtotalVal;
subtotalVal = 0;
var taxVal;
taxVal = 0;
var totalVal;
totalVal = 0;
var strSubtotalVal;
var strTaxVal;
var strTotalVal;
var SYC6FTtempVal;
SYC6FTtempVal = document.surestopform["SYC6FT"].value;
var SYC6FCtempVal;
SYC6FCtempVal = document.surestopform["SYC6FC"].value;
var SYC1FF2tempVal;
SYC1FF2tempVal = document.surestopform["SYC1FF2"].value;
var SYC7TA1tempVal;
SYC7TA1tempVal = document.surestopform["SYC7TA1"].value;
var SYC8T2tempVal;
SYC8T2tempVal = document.surestopform["SYC8T2"].value;
var SYC8TAC2tempVal;
SYC8TAC2tempVal = document.surestopform["SYC8TAC2"].value;
var SYC650BBtempVal;
SYC650BBtempVal = document.surestopform["SYC650BB"].value;
if ((SYC6FTtempVal == "" || (SYC6FTtempVal == " " || (SYC6FTtempVal == " " )|| (SYC6FTtempVal == " ")
{
SYC6FTtempVal = 0;
}
else
{
if (isNaN(SYC6FTtempVal))
SYC6FTtempVal = 0;
else
SYC6FTtempVal = document.surestopform["SYC6FT"].value;
}
if ((SYC6FCtempVal == "" || (SYC6FCtempVal == " " || (SYC6FCtempVal == " " )|| (SYC6FCtempVal == " ")
{
SYC6FCtempVal = 0;
}
else
{
if (isNaN(SYC6FCtempVal))
SYC6FCtempVal = 0;
else
SYC6FCtempVal = document.surestopform["SYC6FC"].value;
}
if ((SYC1FF2tempVal == "" || (SYC1FF2tempVal == " " || (SYC1FF2tempVal == " " )|| (SYC1FF2tempVal == " ")
{
SYC1FF2tempVal = 0;
}
else
{
if (isNaN(SYC1FF2tempVal))
SYC1FF2tempVal = 0;
else
SYC1FF2tempVal = document.surestopform["SYC1FF2"].value;
}
if ((SYC7TA1tempVal == "" || (SYC7TA1tempVal == " " || (SYC7TA1tempVal == " " )|| (SYC7TA1tempVal == " ")
{
SYC7TA1tempVal = 0;
}
else
{
if (isNaN(SYC7TA1tempVal))
SYC7TA1tempVal = 0;
else
SYC7TA1tempVal = document.surestopform["SYC7TA1"].value;
}
if ((SYC8T2tempVal == "" || (SYC8T2tempVal == " " || (SYC8T2tempVal == " " )|| (SYC8T2tempVal == " ")
{
SYC8T2tempVal = 0;
}
else
{
if (isNaN(SYC8T2tempVal))
SYC8T2tempVal = 0;
else
SYC8T2tempVal = document.surestopform["SYC8T2"].value;
}
if ((SYC8TAC2tempVal == "" || (SYC8TAC2tempVal == " " || (SYC8TAC2tempVal == " " )|| (SYC8TAC2tempVal == " ")
{
SYC8TAC2tempVal = 0;
}
else
{
if (isNaN(SYC8TAC2tempVal))
SYC8TAC2tempVal = 0;
else
SYC8TAC2tempVal = document.surestopform["SYC8TAC2"].value;
}
if ((SYC650BBtempVal == "" || (SYC650BBtempVal == " " || (SYC650BBtempVal == " " )|| (SYC650BBtempVal == " ")
{
SYC650BBtempVal = 0;
}
else
{
if (isNaN(SYC650BBtempVal))
SYC650BBtempVal = 0;
else
SYC650BBtempVal = document.surestopform["SYC650BB"].value;
}
//alert (SYC6FTtempVal);
//alert(document.surestopform["SYC6FT"].value);
document.surestopform["SYC6FTval"].value = SYC6FTtempVal;
document.surestopform["SYC6FCval"].value = SYC6FCtempVal;
document.surestopform["SYC1FF2val"].value = SYC1FF2tempVal;
document.surestopform["SYC7TA1val"].value = SYC7TA1tempVal;
document.surestopform["SYC8T2val"].value = SYC8T2tempVal;
document.surestopform["SYC8TAC2val"].value = SYC8TAC2tempVal;
document.surestopform["SYC650BBval"].value = SYC650BBtempVal;
subtotalVal = (SYC6FTtempVal * 24.95) + (SYC6FCtempVal * 24.95) + (SYC1FF2tempVal * 21.95) + (SYC7TA1tempVal * 29.95) + (SYC8T2tempVal * 39.95) + (SYC8TAC2tempVal * 49.95) + (SYC650BBtempVal * 99.95);
//alert(subtotalVal);
subtotalVal = Math.round(subtotalVal *100)/100;
taxVal = Math.round((subtotalVal * .055)*100)/100;
totalVal = Math.round((subtotalVal + taxVal)*100)/100;
strSubtotalVal = subtotalVal + "";
strTaxVal = taxVal + "";
strTotalVal = totalVal + "";
document.surestopform["subtotal"].value = formatNum(strSubtotalVal);
document.surestopform["tax"].value = formatNum(strTaxVal);
document.surestopform["total"].value = formatNum(strTotalVal); // Math.round(totalVal*100)/100;
var brows = navigator.appName;
alert(brows);
var browsvers = navigator.appVersion;
//alert(browsvers.charAt(0));
if((navigator.appName == "Netscape" && (browsvers.charAt(0) == 5))
{
alert("it's netscape"
location.reload(true);
//document.window.reload();
}
//{ alert(browsvers.charAt(0)); }
//
}
function formatNum(tempVal)
{
var newVal;
var aft;
if(tempVal.indexOf("." == -1)
{
newVal = tempVal + ".00";
return newVal;
}
else
{
aft = tempVal.substring(tempVal.indexOf(".",tempVal.length);
if(aft.length == 2)
{
newVal = tempVal + "0";
return newVal;
}
else
{ return tempVal; }
}
}