Hi all,
I am working in apex 4.2.1.
I'm having an odd problem with a checkbox on a tabular form. I created the checkbox by setting hte display as to "Simple Checkbox". The value of the underlying column sets to "Y" wehn checked and "N" when unchecked. This is what I want. The next thing I was trying to accomplish is to call a javascript function when the checkbox is clicked. So I put onclick="calculateTotal(this);" in the element attributes field. The code that it is calling is listed below. When I run the app and check the box I can seee I am entering the calculateTotal function. Each of the alert functions is displaying what I would expect until I get to alerts 'IAH5' and 'IAH6'. For each of those I get an "undefined" in the alert.
So to see if this had soemthing to do with the checkbox and added an onchange="calculateTotal(this);" to another field in my tabular form and ran it. This time I did not click on the checkbox but went into the field that I put the onchange on. When I changed this field and navigated away from it the function worked as I would expect. It displayed the appropriate values for each of the alerts and updated the fields on the screen as designed.
Does anyone have any suggestions as to what might be wrong?
Any help would be appreciated.
Tom
<script type="text/javascript">
function calculateTotal(pThis)
{
alert('IAH1');
var vRow = pThis.id.substr(pThis.id.indexOf('_')+1);
alert('IAH2');
var vPerformedOn = $v('P19_PERFORMED_ON');
alert('IAH3 performed on '+vPerformedOn);
var vPerformedMileage = $v('P19_PERFORMED_MILEAGE');
alert('IAH4 performed mileage '+vPerformedMileage);
html_GetElement('f08_'+vRow).value = vPerformedOn;
alert('IAH5 '+html_GetElement('f08_'+vRow).value);
html_GetElement('f10_'+vRow).value = parseInt(vPerformedMileage,10);
alert('IAH6 '+html_GetElement('f10_'+vRow).value);
}
</script>