0

can anyone help me to add the result to be displayed in the new div tag?(FLAMES game)

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Flames</title> <link href="https://fonts.googleapis.com/css2?family=Syncopate:wght@700&display=swap" rel="stylesheet"> <script> function alphaOnly(event) { var key = event.keyCode; return ((key >= 65 && key <= 90) || key == 8); }; function flame_func() { var name1 = document.getElementById('name1').value; var name2 = document.getElementById('name2').value; var result=document.getElementsById("result"); if(name1 == "") { alert("Enter your name") } else if (name2 == "") { alert("Enter your crush name") } var first = name1; var sec = name2; for(i=0;i<name1.length;i++) { sec = sec.replace(name1[i],''); } for(i=0;i<name2.length;i++) { first = first.replace(name2[i],""); } var final = first+sec; //Main function begins here var final_length = final.length; //flames totally 6 letters var letters = final_length; if(letters == "3"||letters == "5"||letters == "14"||letters == "16"||letters == "18") { alert("friends"); } else if (letters == "10"||letters == "19") { alert("lovers"); } else if (letters == "8"||letters == "12"||letters == "13"||letters == "17") { alert("affection"); } else if (letters == "6"||letters == "11"||letters == "15") { alert("marriage") } else if (letters == "2"||letters == "4"||letters == "7"||letters == "9"||letters == "20") { alert("enemies"); } else i

21st Sep 2020, 4:50 PM
Sai Dinesh
Sai Dinesh - avatar
1 Answer
+ 4
Please put this in a code and share it as a code instead, it gets a bit hard to follow the code without being able to see the text formatting and running it to see the output Nevertheless In the HTML <div id="output_div"></div> In the JavaSricpt // The value you want to output var output = 2; //Get the div you want and set it to set and actually set it's content document.getEleenetById("output_div).innerHTML = output; That should make any div disolay the output Good luck on your coding adventure
21st Sep 2020, 5:24 PM
Vachila64☕
Vachila64☕ - avatar