1. Established members are members that have a few extra features because they contributed something useful that
    this forum community. It's not actually hard to become an established member, but does require some minimal effort.
    Click here for more info
    Dismiss Notice
  2. Dismiss Notice
  3. Join LTN Telegram Group @ LTN TELEGRAM GROUP
    Dismiss Notice

Simple JavaScript love calculator code

Discussion in 'PROGRAMMING' started by Abdulmuhd, Jan 11, 2019.

  1. Abdulmuhd

    Abdulmuhd Leecher Established

    Messages:
    72
    Likes Received:
    14
    Trophy Points:
    8
    <!DOCTYPE html>
    <html>
    <style>
    body {font-size: 180%;font-weight: bolder;text-transform: uppercase; background-color: lightgrey; color: darkgreen }
    input {text-transform: capitalize;}
    div {font-weight: bolder;color: maroon; border: 2px double green; font-size: 150%}
    button { color: green;font-weight: bold;font-size: 100%;width: 180px; height: 60px;}

    input { font-size: 30px;height: 40px ;width: 180px ;}
    </style>
    <body>

    <fieldset>
    <legend>Designed by ABDULRAHMAN.</legend><p style="color: maroon; text-align: center; border: 1px dotted green;" direction="center">LOVE CALCULATOR</p><br/>
    <center>Your Name: <input type ="text" id="yourname"/></center><br/><br/><center>
    Your Lover: <input type="text" id="yourlover"/><center>
    <br/><br/>
    <button onclick="lovecal()">CALCULATE</button><br/></br>
    <div id ="demo"></div><br/></br>
    <div id="dem"></div>
    <p ="poor"></p>
    </fieldset>

    <script>

    function lovecal() { var yourname = document.getElementById("yourname").value;
    var yourlover = document.getElementById("yourlover").value;

    var Calc = Math.floor(Math.random() * 100) + 1
    if (yourname == "" || yourlover == "" ) { alert("Please input the names and try again"); return false;}

    else if (yourname.length < 3 || yourname.length >= 12) { alert("Your name must be greater than 2 & less than 12 characters!"); return false ;}

    else if (yourlover.length < 3 || yourlover.length >= 12) { alert("Lovers name must be greater than 2 & less than 12 characters"); return false ;}

    else if (Calc >= 60) {document.getElementById("dem").innerHTML = `${yourname} You Love ${yourlover} Very Much! <br>Keep it up.`}

    else if (Calc >= 50) {document.getElementById("dem").innerHTML = `${yourname} and ${yourlover} your love is average! <br>You need to Improve.`}

    else if (Calc < 50) {document.getElementById("dem").innerHTML = `${yourname} You don't Love ${yourlover} Much! <br>You need to Work hard.`}

    document.getElementById("demo").innerHTML ="Your Love is "+ Calc+"%" ;}
    </script>
    </body>
    </html>
     
  2. Loading...


  3. thafweshgeek

    thafweshgeek Guru Established

    Messages:
    3,404
    Likes Received:
    149
    Trophy Points:
    63

Share This Page

Loading...