• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2098
  • Last Modified:

Javascript not working in Google Chrome & Safari

The following works fine in IE & Mozzilla but does not in Google Chrome or Safari.
Can anyone help me with where I am going wrong with this?
I cannot find where the problem is occuring yet am guessing it will be totally obvious.

Any help appreciated.
Thanks,
Matt
<script type="text/javascript">
function ReCalculate()
{
var BookQty=(parseFloat(window.document.getElementById("AdQty").value) + parseFloat(window.document.getElementById("CoQty").value) + parseFloat(window.document.getElementById("ChQty").value) + parseFloat(window.document.getElementById("SeQty").value) + parseFloat(window.document.getElementById("FdaQty").value) + parseFloat(window.document.getElementById("FdcQty").value));
window.document.getElementById("BookingQty").value= BookQty;
 
if(BookQty>10)
{
alert("You cannot select more then 10 tickets or you will be unable to proceed.");
window.document.getElementById("Proceed").disabled=true;
}
else
{
window.document.getElementById("Proceed").disabled=false;
}
 
 
 
var BookingValue=(toDollarsAndCents(document.getElementById("BookingQty").value * 1));
window.document.getElementById("BookValue").innerHTML = "$" + BookingValue;
 
var AdValue=(toDollarsAndCents(document.getElementById("AdQty").value *  parseFloat(window.document.getElementById("AdPrice").value) ));
window.document.getElementById("AdultValue").innerHTML = "$" + AdValue;
 
var CoValue=(toDollarsAndCents(document.getElementById("CoQty").value *  parseFloat(window.document.getElementById("CoPrice").value) ));
window.document.getElementById("ConcessionValue").innerHTML = "$" + CoValue;
 
var ChValue=(toDollarsAndCents(document.getElementById("ChQty").value *  parseFloat(window.document.getElementById("ChPrice").value) ));
window.document.getElementById("ChildValue").innerHTML = "$" + ChValue;
 
var SeValue=(toDollarsAndCents(document.getElementById("SeQty").value *  parseFloat(window.document.getElementById("SePrice").value) ));
window.document.getElementById("SeniorValue").innerHTML = "$" + SeValue;
 
var FdaValue=(toDollarsAndCents(document.getElementById("FdaQty").value *  parseFloat(window.document.getElementById("FdaPrice").value) ));
window.document.getElementById("FamadValue").innerHTML = "$" + FdaValue;
 
var FdcValue=(toDollarsAndCents(document.getElementById("FdcQty").value *  parseFloat(window.document.getElementById("FdcPrice").value) ));
window.document.getElementById("FamchValue").innerHTML = "$" + FdcValue;
 
 
var OrderTotal=(toDollarsAndCents((parseFloat(AdValue) + parseFloat(CoValue) + parseFloat(ChValue) + parseFloat(SeValue) + parseFloat(FdcValue) + parseFloat(FdaValue) + parseFloat(BookingValue))));
window.document.getElementById("OrderTotal").innerHTML = "$" + OrderTotal;
 
}
 
 
function toDollarsAndCents(n) {
  var s = "" + Math.round(n * 100) / 100;
  var i = s.indexOf('.');
  if(i < 0) return s + ".00";
  var t = s.substring(0, i + 1) + s.substring(i + 1, i + 3);
  if (i + 2 == s.length) t += "0";
  return t;
}
 
 
</script>

Open in new window

0
mhanslow
Asked:
mhanslow
2 Solutions
 
prokvkCommented:
You know I cant figure anything from this code you pasted ... I can call those functions but they use DOM elements, so it'll be pointless .. Try to paste the whole code of the page that's not working.
0
 
mhanslowAuthor Commented:
I ended up just re-doing it. Problem solved.

Still not sure where it was wrong.
<script type="text/javascript">
function ReCalculate()
{
//Get the Quantities
var AdQty=document.BuyTix.AdQty.value;
var CoQty=document.BuyTix.CoQty.value;
var ChQty=document.BuyTix.ChQty.value;
var SeQty=document.BuyTix.SeQty.value;
var FdaQty=document.BuyTix.FdaQty.value;
var FdcQty=document.BuyTix.FdcQty.value;
 
//Get the prices
var AdPrice=document.BuyTix.AdPrice.value;
var CoPrice=document.BuyTix.CoPrice.value;
var ChPrice=document.BuyTix.ChPrice.value;
var SePrice=document.BuyTix.SePrice.value;
var FdaPrice=document.BuyTix.FdaPrice.value;
var FdcPrice=document.BuyTix.FdcPrice.value;
 
//Get the Quantity of Booking Fees
var BookingQty=parseFloat(AdQty)+parseFloat(CoQty)+parseFloat(ChQty)+parseFloat(SeQty)+parseFloat(FdaQty)+parseFloat(FdcQty);
 
 
//Calculate Line Totals
document.getElementById("AdultValue").innerHTML = "$" + toDollarsAndCents(AdPrice*AdQty);
document.getElementById("ConcessionValue").innerHTML = "$" + toDollarsAndCents(CoPrice*CoQty);
document.getElementById("ChildValue").innerHTML = "$" + toDollarsAndCents(ChPrice*ChQty);
document.getElementById("SeniorValue").innerHTML = "$" + toDollarsAndCents(SePrice*SeQty);
document.getElementById("FamadValue").innerHTML = "$" + toDollarsAndCents(FdaPrice*FdaQty);
document.getElementById("FamchValue").innerHTML = "$" + toDollarsAndCents(FdcPrice*FdcQty);
 
 
//Caculate Booking Fee
document.BuyTix.BookingQty.value=BookingQty;
document.getElementById("BookValue").innerHTML = "$" + toDollarsAndCents(1*BookingQty);
 
//Caculate Order Total
var OrderTotal = ((AdPrice*AdQty)+(CoPrice*CoQty)+(ChPrice*ChQty)+(SePrice*SeQty)+(FdaPrice*FdaQty)+(FdcPrice*FdcQty)+(BookingQty));
document.getElementById("OrderTotal").innerHTML = "$" + toDollarsAndCents(OrderTotal);
 
 
//Only Allow 10 tickets
if(BookingQty>10)
{
document.getElementById("Proceed").disabled=true;
alert("You have selected more then 10 tickets! \n Only 10 tickets are allowed for each transaction. \n\n Please select less tickets and try again.");
}
else
{
document.getElementById("Proceed").disabled=false;
}
 
 
 
 
 
function toDollarsAndCents(n) {
  var s = "" + Math.round(n * 100) / 100;
  var i = s.indexOf('.');
  if(i < 0) return s + ".00";
  var t = s.substring(0, i + 1) + s.substring(i + 1, i + 3);
  if (i + 2 == s.length) t += "0";
  return t;
}}
 
 
</script>

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now