I have a problem here, my code for elseif statement is not working I & amp; Amp; & Amp; Amp; & Amp; Operator in HTML or javascript?
& lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Body & gt; & Lt; P & gt; & Lt; Font color = "blue" size = 23 & gt; Compute letter grade & lt; / Font & gt; & Lt; / P & gt; & Lt; Br> & Lt; Br> & Lt; Label = "numericgrade" & gt; & Lt; Font size = 5> Enter numerical grade & lt; Font & gt; & Lt; / Label & gt; & Amp; Nbsp & amp; Nbsp; & Amp; Nbsp & amp; Nbsp; And & amp; Nbsp & amp; Nbsp & amp; Nbsp; & Amp; Nbsp; & Amp; Nbsp; & Lt; Input type = "article" id = "txtgrade" style = "width: 30px" & gt; & Lt; / Input & gt; & Lt; Br> & Lt; Br> & Lt; Br> & Lt; Button onclick = "myfunction ()" style = "height: 50px; width: 400px" & gt; Letter of letter & lt; / Button & gt; & Lt; P id = "demo" & gt; & Lt; / P & gt; & Lt; Script & gt; Function myFunction () {if (document.getElementById ("txtgrade"). Value & gt; = 90) {document.getElementById ("Demo"). InnerHTML = "letter grade 'A'"; } Else if (document.getElementById ("txtgrade"). Value & gt; = 80 & amp; amp; document .getElementById ("txtgrade") value & lt; 90) {document.getElementById ("Demo"). InnerHTML = "Letter is grade 'B';} & lt; / script> & lt; / body & gt; & lt; / html & gt;
You can modify your script in this way. Since you are checking the grade for more than 80 in the second part, In addition, your braces were missing.
script> function myFunction () {var grade = document.getElementById ("txtgrade"); If (Grade.value> = 90) {document.getElementById ("Demo"). InnerHTML = "Letter grade 'A'"} Else if (grade.value> = 80) {document.getElementById ("Demo ") InnerHTML = "letter grade" B ' ";}} & Lt; / script & gt;
No comments:
Post a Comment