I have a simple popup calculator used to generate a Body Mass Index calculation. It takes inputs of Height in Feet, Height in inches, and weight, then calculates BMI. I have a working example in 3.2, but I am trying to get it to work in 4.1 and can't seem to get things in the right spot.
In 4.1, there is a new region area called JavaScript. Can someone explain what this is for and how to use it? Here is the code that works in 3.2 when placed in the HTML header portion of the page:
<script language="JavaScript" type="text/javascript">
function calcBMI(formItem1, formItem2, formItem3, formItem4) {
var bmift = document.getElementById(formItem1).value;
var bmiin = document.getElementById(formItem2).value;
var bmiht = bmift*12 + parseInt(bmiin);
var bmiwt = document.getElementById(formItem3).value*703;
var bmi = Math.round(bmiwt/(bmiht*bmiht)*100)/100;
document.getElementById(formItem4).value = bmi;
}
function passBMIBack(passVal1)
{
var bmi = document.getElementById(passVal1).value;
opener.document.getElementById("P1431_BMI").value = bmi;
opener.document.getElementById("P1431_BMI").focus();
window.close();
}
</script>
The top one is the calculation. The bottom one passes the calculated value back to the parent page. Each of the three input page items has this in the HTML Form Attributes:
onblur=calcBMI('P1432_FT','P1432_IN','P1432_WT','P1432_BMI')
I also tried getting this to work via a Dynamic Action triggered based on a change in the Height field to calculate the BMI via the following SQL. I verified that the SQL is correct, but the value gets set to NULL rather than the calculated value. Here's the SQL:
select ROUND((:P523_WT*703)/POWER((:P523_FT*12+:P523_IN),2),2) from dual
Ideally, I'd like to get both of these figured out so I can use them, but whatever works is top priority. Thanks.