I have this script running on a page but I'm getting errors on safari browsers and firefox doesn't like it much either. I appreciate assistance in correcting this.
<!-- begin cloaking from non-JavaScript browsers.
// Written by: Paul DeBrino of Infinity Research and Development.
// Email: IRandD@aol.com
//Define function to manipulate the form total per item selected/deselected:
function oneOrNocheckboxGroup (checkbox) {
var checkboxGroup = checkbox.form[checkbox.name];
for (var c = 0; c < checkboxGroup.length; c++)
if (checkboxGroup[c] != checkbox)
checkboxGroup[c].checked = false;
}
function radioCheckboxGroup (checkbox) {
var checkboxGroup = checkbox.form[checkbox.name];
for (var c = 0; c < checkboxGroup.length; c++)
if (checkboxGroup[c] != checkbox)
checkboxGroup[c].checked = false;
return checkbox.checked;
}
function CheckChoice(whichbox)
{
with (whichbox.form)
{
//Handle differently, depending on type of input box.
if (whichbox.type == "radio")
{
hiddenpriorradio.value = eval(whichbox.price);
//Now, apply the current radio selection's price to the total:
hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.price);
}
else
{
//If box was checked, accumulate the checkbox value as the form total,
//Otherwise, reduce the form total by the checkbox value:
if (whichbox.checked == false)
{ hiddentotal.value = eval(hiddentotal.value) - eval(whichbox.value); }
else { hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.value); }
}
//Ensure the total never goes negative (some browsers allow radiobutton to be deselected):
//Now, return with formatted total:
return(formatCurrency(hiddentotal.value));
}
}
//Define function to setup form fields/buttons/checkbox that..
//..have non-HTML compliant properties (Netscape requires this, however
//..IE works by simply specifying these properties directly on the
//..INPUT specification):
function setInput(whichbox,myprice) {
with (whichbox.form)
{
//Only do this once per input field:
if (!whichbox.price)
{
whichbox.price = myprice;
whichbox.priorval = 0;
}
}
}
//Define function to format a value as currency:
function formatCurrency(num)
{
<!-- Function courtesy of: Cyanide_7 (leo7278@hotmail.com) -->
<!-- Web Site: -->
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num)) num = "0";
num = Math.floor((num*100+0.5)/100).toString();
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
return (num);
}
//Define function to init the form on reload:
function InitForm()
{
//Reset the displayed total on form:
document.myform.total.value='0';
document.myform.hiddentotal.value=0;
document.myform.hiddenpriorradio.value=0;
//Set all checkboxes and radio buttons on form-1 to unchecked:
for (xx=0; xx < document.myform.elements.length; xx++)
{
if (document.myform.elements[xx].type == 'checkbox' | document.myform.elements[xx].type == 'radio')
{
document.myform.elements[xx].checked = false;
}
}
}
"Away from the actual ... everything is virtual"
<!-- begin cloaking from non-JavaScript browsers.
// Written by: Paul DeBrino of Infinity Research and Development.
// Email: IRandD@aol.com
//Define function to manipulate the form total per item selected/deselected:
function oneOrNocheckboxGroup (checkbox) {
var checkboxGroup = checkbox.form[checkbox.name];
for (var c = 0; c < checkboxGroup.length; c++)
if (checkboxGroup[c] != checkbox)
checkboxGroup[c].checked = false;
}
function radioCheckboxGroup (checkbox) {
var checkboxGroup = checkbox.form[checkbox.name];
for (var c = 0; c < checkboxGroup.length; c++)
if (checkboxGroup[c] != checkbox)
checkboxGroup[c].checked = false;
return checkbox.checked;
}
function CheckChoice(whichbox)
{
with (whichbox.form)
{
//Handle differently, depending on type of input box.
if (whichbox.type == "radio")
{
hiddenpriorradio.value = eval(whichbox.price);
//Now, apply the current radio selection's price to the total:
hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.price);
}
else
{
//If box was checked, accumulate the checkbox value as the form total,
//Otherwise, reduce the form total by the checkbox value:
if (whichbox.checked == false)
{ hiddentotal.value = eval(hiddentotal.value) - eval(whichbox.value); }
else { hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.value); }
}
//Ensure the total never goes negative (some browsers allow radiobutton to be deselected):
//Now, return with formatted total:
return(formatCurrency(hiddentotal.value));
}
}
//Define function to setup form fields/buttons/checkbox that..
//..have non-HTML compliant properties (Netscape requires this, however
//..IE works by simply specifying these properties directly on the
//..INPUT specification):
function setInput(whichbox,myprice) {
with (whichbox.form)
{
//Only do this once per input field:
if (!whichbox.price)
{
whichbox.price = myprice;
whichbox.priorval = 0;
}
}
}
//Define function to format a value as currency:
function formatCurrency(num)
{
<!-- Function courtesy of: Cyanide_7 (leo7278@hotmail.com) -->
<!-- Web Site: -->
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num)) num = "0";
num = Math.floor((num*100+0.5)/100).toString();
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
return (num);
}
//Define function to init the form on reload:
function InitForm()
{
//Reset the displayed total on form:
document.myform.total.value='0';
document.myform.hiddentotal.value=0;
document.myform.hiddenpriorradio.value=0;
//Set all checkboxes and radio buttons on form-1 to unchecked:
for (xx=0; xx < document.myform.elements.length; xx++)
{
if (document.myform.elements[xx].type == 'checkbox' | document.myform.elements[xx].type == 'radio')
{
document.myform.elements[xx].checked = false;
}
}
}
"Away from the actual ... everything is virtual"