JavaScript to input data and produce results bases on input [on hold]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


JavaScript to input data and produce results bases on input [on hold]



I need help pls....i would like to create a script that creates different results when clicking on a button bases on if statements. For example....i need to have choices bases on radio buttons so if the first button is male or female then outcome is 'a customized statement. Then I would to continue the output statement based on their age whether under or over 21 so then the statement would be changed. And also if body mass index is greater or less than a particular number then a new statement would be produced when the button is clicked. So if the choices are male, over 21 and a bmi of 120 the the outcome is 'loose weight'. Can some somebody assist with a JavaScript for this please?



Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.





What have you done so far to achieve this?
– hev1
yesterday





All that has been posted is a program description. However, we need you to ask a question. We can't be sure what you want from us. Please edit your post to include a valid question that we can answer. Reminder: make sure you know what is on-topic here; asking us to write the program for you and suggestions are off-topic.
– FrankerZ
yesterday





Ok this is my first time here so I'll make the adjustments so that my request can be a little more clearer
– everettejr
yesterday




1 Answer
1



You can check the value of the radio button or select that was chosen to show a message. You should give the radio buttons and select options values that are easily to interpret and use in your code.




<form>
Gender:<br/>
<input type="radio" name="Gender" value="Male"/>Male
<input type="radio" name="Gender" value="Female"/>Female
<br/>
<span id="genderresult"></span>
<br/>
Body Mass Index:<br/>
<select id="bmi" onchange="showChange()">
<option value="under 18.5">&lt;18.5</option>
<option value="18.5 to 24.9">18.5-24.9</option>
<option value="25 to 29">25-29</option>
<option value="over 30">30+</option>
</select>
<br/>
<span id="bmiresult"></span>
</form>
<script>
var radioButtons = document.querySelectorAll('input[type=radio]');
var genderresult = document.getElementById("genderresult");
var bmiresult = document.getElementById("bmiresult");
radioButtons.forEach(r=>{
r.onclick = function(e){
genderresult.innerHTML = "You are "+r.value;
}
});
function showChange(){
var bmi = document.getElementById("bmi").value;
bmiresult.innerHTML = "Your body mass index is "+bmi;
if(bmi=="over 30"){
bmiresult.innerHTML += "<br/>Consider losing weight";
}
}
</script>





Great theory, I'll give it a try and let you know how it goes....thanks!!
– everettejr
yesterday





@everettejr No problem.
– hev1
yesterday

Popular posts from this blog

Keycloak server returning user_not_found error when user is already imported with LDAP

PHP parse/syntax errors; and how to solve them?

How to scale/resize CVPixelBufferRef in objective C, iOS