Mel Parish
asked on
Calculate function not working in FF or Chrome, fine in IE
I have the following calculate function which is not working in FF or chrome. Works great in IE. Here are the fields that should change but do not update in FF or chrome. Any thoughts would be greatly appreciated. Thank you.
<input type="text" name="a3" id="a3" value="$11.75" align="right" size=7 readonly style="text-align: right; font-weight: bolder;">
<input type="text" name="a4" id="a4" value="$0.89" size="7" readonly style="text-align: right; font-weight: bolder;">
<input type="text" name="total" id="total" value="$12.64" size="7" readonly style="text-align: right; font-weight: bolder;">
<input type="text" name="a3" id="a3" value="$11.75" align="right" size=7 readonly style="text-align: right; font-weight: bolder;">
<input type="text" name="a4" id="a4" value="$0.89" size="7" readonly style="text-align: right; font-weight: bolder;">
<input type="text" name="total" id="total" value="$12.64" size="7" readonly style="text-align: right; font-weight: bolder;">
<script>
function calculate(f)
{
var num=parseInt(f.quantity.options[f.quantity.options.selectedIndex].value);
var cost=(7.95+4.95);
var tax=.0825
if(document.getElementById('billState').value != "TX") //replace MY_STATE_DDL_ID with the control ID of your state drop down list
{
tax = 0;
}
f.a3.value="$"+(((num*cost)).toFixed(2));
var tax2=(((num*cost))*tax);
f.a4.value="$"+tax2.toFixed(2);
f.total.value="$"+((tax2+((num*cost))).toFixed(2));
pieces=f.a3.value.split('.');
pieces[1]=(pieces[1]) ? pieces[1]+'00' : '00';
//f.a3.value=pieces[0]+'.'+(pieces[1]).substr(0,2);
}
</script>
Have you tested it by taking the readonly flag off? If you have to keep it in the textbox properties, you could toggle it in another function.
it is working on my FF
shows
$11.75 $0.89 $12.64
same in IE
shows
$11.75 $0.89 $12.64
same in IE
ASKER
Shoot, i removed readonly but it made no difference, ugh. Good idea though.
ASKER
I should have said when the quantity changes. That's where it works in IE but on in FF or CHrome.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The sample I posted above also works fine in FF :)
you should post a running sample, we cannot predict what your code and find the issue...
you should post a running sample, we cannot predict what your code and find the issue...
if you aggree on my sample working, then compare that one with your code
look for select elements, do you have value defined? do you have id & name for each element? did you use onChange event handler? do you refer to form correctly?
look for select elements, do you have value defined? do you have id & name for each element? did you use onChange event handler? do you refer to form correctly?
ASKER
Yes, thank you very much for your help.