jackfusion
Programmer
- Aug 28, 2007
- 3
I am working with google forms to create a canteen Cash report. The form works in PC/MAC IE, Chrome, Safari but not in firefox. The problem is the grand total for each table will not update because it is a string and when I use Number(), parseFloat() or parseInt( ,10) it will not work to convert it to a number Why is that?
I cannot change any of the names or ids in the HTML because those parts are linked to the google spreadsheet some how. I have included all my code. I could only put in part of the code because then there is too many characters for the post. Here is the link http://yftg.ca/canteencashreport.htm"][/URL]
I cannot change any of the names or ids in the HTML because those parts are linked to the google spreadsheet some how. I have included all my code. I could only put in part of the code because then there is too many characters for the post. Here is the link http://yftg.ca/canteencashreport.htm"][/URL]
Code:
function runtotal(myform) {
alert(typeof(entry_46.value))
var oc_cent1 = Number(document.getElementById('entry_1').value);
var oc_cent5 = Number(document.getElementById('entry_3').value);
var oc_cent10 = Number(document.getElementById('entry_5').value);
var oc_cent25 = Number(document.getElementById('entry_7').value);
var oc_dollar1 = Number(document.getElementById('entry_9').value);
var oc_dollar2 = Number(document.getElementById('entry_11').value);
var oc_dollar5 = Number(document.getElementById('entry_13').value);
var oc_dollar10 = Number(document.getElementById('entry_15').value);
var oc_dollar20 = Number(document.getElementById('entry_17').value);
var oc_otherq = Number(document.getElementById('entry_19').value);
var oc_othert = Number(document.getElementById('entry_20').value);
myform.entry_2.value = (0.01 * oc_cent1).toFixed(2);
myform.entry_4.value = (0.05 * oc_cent5).toFixed(2);
myform.entry_6.value = (0.10 * oc_cent10).toFixed(2);
myform.entry_8.value = (0.25 * oc_cent25).toFixed(2);
myform.entry_10.value = (1.00 * oc_dollar1).toFixed(2);
myform.entry_12.value = (2.00 * oc_dollar2).toFixed(2);
myform.entry_14.value = (5.00 * oc_dollar5).toFixed(2);
myform.entry_16.value = (10.00 * oc_dollar10).toFixed(2);
myform.entry_18.value = (20.00 * oc_dollar20).toFixed(2);
myform.entry_21.value = (oc_otherq * oc_othert).toFixed(2);
myform.entry_22.value = (parseFloat(entry_2.value) + parseFloat(entry_4.value) + parseFloat(entry_6.value) + parseFloat(entry_8.value) + parseFloat(entry_10.value) + parseFloat(entry_12.value) + parseFloat(entry_14.value) + parseFloat(entry_16.value) + parseFloat(entry_18.value) + parseFloat(entry_21.value)).toFixed(2);
Code:
<html><head>
<title>Canteen Cash Report</title>
<link href='cashreport1.css' type='text/css' rel='stylesheet'>
<script type="text/javascript" src="totals.js"></script>
</head>
<body class="ss-base-body" dir="ltr" itemscope itemtype="[URL unfurl="true"]http://schema.org/CreativeWork/FormObject"><meta[/URL] itemprop="name" content="Canteen Cash Report">
<div class="ss-form-container">
<div class="ss-form-heading">
<h1 class="ss-form-title">Canteen Cash Report</h1>
<p></p>
<div class="ss-form-desc ss-no-ignore-whitespace">
Please make sure that you review everything as being correct before you click submit.<br />
Please enter in other currencies and the total in the other boxes. Example ($50 * 1)($50.00). We do not accept foreign currency.
</div>
<p></p>
<hr class="ss-email-break" style="display:none;">
</div>
<div class="ss-form"><form action="google form" method="POST" id="ss-form">
<div class="1container">
<div class="square3">
<div class="container">
<div class="title">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<label class="ss-q-title" for="entry_0">Opening Cash</label>
</div>
</div>
</div>
</div>
<div class="container">
<div class="label">
<div class="ss-item ss-text">
<div class="ss-form-entry">
</div>
</div>
</div>
<div class="label">
<div class="ss-item ss-text">
<div class="ss-form-entry bold">
<center>Quantity</center>
</div>
</div>
</div>
<div class="label">
<div class="ss-item ss-text">
<div class="ss-form-entry bold">
<center>Total</center>
</div>
</div>
</div>
</div>
<div class="container">
<div class="label">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<center><b>Example $ 0.25</b></center>
</div>
</div>
</div>
<div class="label">
<div class="ss-item ss-text">
<div class="ss-form-entry bold">
<center>20</center>
</div>
</div>
</div>
<div class="label">
<div class="ss-item ss-text">
<div class="ss-form-entry bold">
<center>$ 5.00</center>
</div>
</div>
</div>
</div>
<div class="container">
<div class="label">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<label class="ss-q-title" for="entry_1">$ 0.01</label>
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.1.single" size="10" value="0" class="ss-q-short" id="entry_1" onChange="runtotal(this.form)" tabindex="1">
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.2.single" size="10" value="0" class="ss-q-short" id="entry_2" onFocus="this.form.elements[0].focus()">
</div>
</div>
</div>
</div>
<div class="container">
<div class="label">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<label class="ss-q-title" for="entry_3">$ 0.05</label>
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.3.single" size="10" value="0" class="ss-q-short" id="entry_3" onChange="runtotal(this.form)" tabindex="2">
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.4.single" size="10" value="0" class="ss-q-short" id="entry_4" onFocus="this.form.elements[0].focus()">
</div>
</div>
</div>
</div>
<div class="container">
<div class="label">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<label class="ss-q-title" for="entry_5">$ 0.10</label>
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.5.single" size="10" value="0" class="ss-q-short" id="entry_5" onChange="runtotal(this.form)" tabindex="3">
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.6.single" size="10" value="0" class="ss-q-short" id="entry_6" onFocus="this.form.elements[0].focus()">
</div>
</div>
</div>
</div>
<div class="container">
<div class="label">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<label class="ss-q-title" for="entry_7">$ 0.25</label>
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.7.single" size="10" value="0" class="ss-q-short" id="entry_7" onChange="runtotal(this.form)" tabindex="4">
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.8.single" size="10" value="0" class="ss-q-short" id="entry_8" onFocus="this.form.elements[0].focus()">
</div>
</div>
</div>
</div>
<div class="container">
<div class="label">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<label class="ss-q-title" for="entry_9">$ 1.00</label>
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.9.single" size="10" value="0" class="ss-q-short" id="entry_9" onChange="runtotal(this.form)" tabindex="5">
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.10.single" size="10" value="0" class="ss-q-short" id="entry_10" onFocus="this.form.elements[0].focus()">
</div>
</div>
</div>
</div>
<div class="container">
<div class="label">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<label class="ss-q-title" for="entry_11">$ 2.00</label>
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.11.single" size="10" value="0" class="ss-q-short" id="entry_11" onChange="runtotal(this.form)" tabindex="6">
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.12.single" size="10" value="0" class="ss-q-short" id="entry_12" onFocus="this.form.elements[0].focus()">
</div>
</div>
</div>
</div>
<div class="container">
<div class="label">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<label class="ss-q-title" for="entry_13">$ 5.00</label>
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.13.single" size="10" value="0" class="ss-q-short" id="entry_13" onChange="runtotal(this.form)" tabindex="7">
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.14.single" size="10" value="0" class="ss-q-short" id="entry_14" onFocus="this.form.elements[0].focus()">
</div>
</div>
</div>
</div>
<div class="container">
<div class="label">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<label class="ss-q-title" for="entry_15">$ 10.00</label>
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.15.single" size="10" value="0" class="ss-q-short" id="entry_15" onChange="runtotal(this.form)" tabindex="8">
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.16.single" size="10" value="0" class="ss-q-short" id="entry_16" onFocus="this.form.elements[0].focus()">
</div>
</div>
</div>
</div>
<div class="container">
<div class="label">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<label class="ss-q-title" for="entry_17">$ 20.00</label>
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.17.single" size="10" value="0" class="ss-q-short" id="entry_17" onChange="runtotal(this.form)" tabindex="9">
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.18.single" size="10" value="0" class="ss-q-short" id="entry_18" onFocus="this.form.elements[0].focus()">
</div>
</div>
</div>
</div>
<div class="container">
<div class="label">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<label class="ss-q-title" for="entry_19">Other</label>
</div>
</div>
</div>
<div class="other">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.19.single" size="2" value="0" class="ss-q-short" id="entry_19" onChange="runtotal(this.form)" tabindex="10">
</div>
</div>
</div>
<div class="other">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.20.single" size="2" value="0" class="ss-q-short" id="entry_20" onChange="runtotal(this.form)" tabindex="11">
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.21.single" size="10" value="0" class="ss-q-short" id="entry_21" onFocus="this.form.elements[0].focus()">
</div>
</div>
</div>
</div>
<div class="container">
<div class="label">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<label class="ss-q-title" for="entry_22">Total</label>
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
</div>
</div>
</div>
<div class="square">
<div class="ss-item ss-text">
<div class="ss-form-entry">
<input type="text" name="entry.22.single" size="10" value="0" class="ss-q-short" id="entry_22" tabindex="12" onFocus="this.form.elements[0].focus()">
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<script type="text/javascript">
(function() {
var divs = document.getElementById('ss-form').
getElementsByTagName('div');
var numDivs = divs.length;
for (var j = 0; j < numDivs; j++) {
if (divs[j].className == 'errorbox-bad') {
divs[j].lastChild.firstChild.lastChild.focus();
return;
}
}
for (var i = 0; i < numDivs; i++) {
var div = divs[i];
if (div.className == 'ss-form-entry' &&
div.firstChild &&
div.firstChild.className == 'ss-q-title') {
div.lastChild.focus();
return;
}
}
})();
</script>
</div>
<input type="submit" name="submit" value="Submit" onClick="runtotal(this.form)">
</body>
</html>