PHRR 5.3 B7474.
On the Javascript Onload event of a edit page
I have a function CalculateTotal with parameters control(checkboxes) and amount, this function checks the state of the control, and adds/subtracts the amount from a field :
function CalculateTotal(control, amount)
{
alert("function triggers");//for testing purposes
var TotalvalcalcTotal = 0;
var ControlState = control.getValue();
var TotalvalcalcTotal = Total.getValue();
if (ControlState == 'on')
{
TotalvalcalcTotal = parseFloat(TotalvalcalcTotal) + amount;
}
else
{
TotalvalcalcTotal = parseFloat(TotalvalcalcTotal) - amount;
}
Total.setValue(TotalvalcalcTotal);
};
and about 30 functions that calls this function with a control and a value as parameters, example:
function calcRTF() {
CalculateTotal(RequireTransportFrom, 490);
};
RequireTransportFrom.on('change', calcRTF);
This code works perfectly on Firefox and Google Chrome:
when I click a code bound checkbox, the code is run (an alert window appears, and Total is updated)
In Internet Explorer this doesn't work correctly:
when I first click a code bound checkbox, nothing happens.
when I click a second code bound checkbox, an alert window appears and the value of the 1st and 2nd checkbox is added to total.
when I clear one of the checked checkboxes, an alert window appears and the associated value is subtracted ([color="#FF8C00"]not both values, so I have a residual value that shouldn't be there)
I state again this just happens in Internet Explorer ( I've tested it on version 9 and 7), not on Firefox or Chrome.
Can someone help, or point me in the right direction?
This get Frustrating <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=59434&image=1&table=forumreplies' class='bbcemoticon' alt='<<' />
Nevermind, I solved my own question...
Change
RequireTransportFrom.on('change', calcRTF);
to
RequireTransportFrom.on('click', calcRTF);
Do this for all checkboxes in your project.
Internet Explorer, I hope you die <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=59434&image=2&table=forumreplies' class='bbc_emoticon' alt=':angry:' />