Using Calculated Field in Conditional Javascript to other output
-
Trying to use the calculation form with document.getElementById and I am unable to run the javascript to do an if statement over the data. After lots of testing I think the issue is the document.getElementById(“risk”).value as I think it is not being picked up to be used in formula. Help appreciated.
Total risk appetite score
[calculation total-riskapp id:risk “your-question1_flag + your-question2_flag + your-question3_flag + your-question4_flag+ your-question5_flag + your-question6_flag”]
Total liquidity score
[calculation total-liqneeds id:liquidity “your-question7_flag + your-question8_flag + your-question9_flag + your-question10_flag” ]
<p>Your investment risk profile id <span id=”investment_profile”></span></p>
<script language=”javascript” type=”text/javascript”>
document.getElementById(“risk”).addEventListener(“change”, displayTextField);
document.getElementById(“liquidity”).addEventListener(“change”, displayTextField);
function displayTextField() {
var r = document.getElementById(“risk”).value;
var l = document.getElementById(“liquidity”).value;
if (r > 60 && l < 50 ) {
document.getElementById(“investment_profile”).innerHTML = ‘Growth’;
} else if ((r >= 30 && l < 75 )||(r > 60 && l > 50 )) {
document.getElementById(“investment_profile”).innerHTML = ‘Balanced’;
} else {
document.getElementById(“investment_profile”).innerHTML = ‘Income’;
}
}
</script>
- The topic ‘Using Calculated Field in Conditional Javascript to other output’ is closed to new replies.