Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Javascript not working in Google Chrome & Safari

Posted on 2009-05-02
2
Medium Priority
?
2,066 Views
Last Modified: 2013-11-10
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
Comment
Question by:mhanslow
2 Comments
 
LVL 5

Assisted Solution

by:prokvk
prokvk earned 80 total points
ID: 24290039
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
 

Accepted Solution

by:
mhanslow earned 0 total points
ID: 24291427
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
Suggested Courses

805 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question