Simple Love Calculator
Submitted by rinvizle on Wednesday, August 17, 2016 - 16:31.
If your looking for a Simple Web Application for entertainment I have here a Simple Love Calculator using PHP and Javascript. This application has a two inputs of a name for the male and female. Every letter or name that the user encode the application will automatically calculate the percentage of love with that two names that the user encode. The calculation of the percentage is driven by the javascript to show how much percentage that the two name will be each other or not. See the example code below.
Index.php - This is for the HTML form and for the rest of javascript code to catch or fetch the data through the calculation.php
Hope that you learn in my tutorial. Don't forget to LIKE & SHARE this website. Enjoy Coding.
Sample Code
Calculator.php - this code is for the calculation of love and convert to percentage.- <?php
- for ($i=97; $i <= 122; $i++)
- {
- if ($alp[$i] != false)
- {
- if ($answer < 2)
- {
- $calc[]=$alp[$i];
- }
- else
- {
- for ($a=0; $a < $answer; $a++)
- {
- }
- }
- }
- }
- {
- for ($i=0; $i < $lettermitte; $i++)
- {
- if ($answer < 2)
- {
- $addcalc[]=$sum;
- }
- else
- {
- for ($a=0; $a < $answer; $a++)
- {
- }
- }
- }
- for ($b=0; $b < $answers; $b++)
- {
- $calc[]=$addcalc[$b];
- }
- }
- echo $calc[0] . $calc[1];
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Simple Love Calculator</title>
- </head>
- <body>
- <script language = "javascript" type = "text/javascript">
- var request = false;
- try
- {
- request = new XMLHttpRequest();
- }
- catch (trymicrosoft)
- {
- try
- {
- request = new ActiveXObject("Msxml2.XMLHTTP");
- }
- catch (othermicrosoft)
- {
- try
- {
- request = new ActiveXObject("Microsoft.XMLHTTP");
- }
- catch (failed)
- {
- request = false;
- }
- }
- }
- if (!request)
- alert("Error initializing XMLHttpRequest!");
- function updateDiv(person1, person2)
- {
- var url = "calculate.php";
- var params = "per1=" + person1 + "&per2=" + person2;
- request.open("POST", url, true);
- request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- request.setRequestHeader("Content-length", params.length);
- request.setRequestHeader("Connection", "close");
- request.onreadystatechange = function()
- {
- if (request.readyState == 4 && request.status == 200)
- {
- var response = request.responseText;
- document.getElementById('targetDiv').innerHTML = response + "% ";
- }
- }
- request.send(params);
- }
- </script>
- <div id = "main" align = "center">
- <form name = "test" action = "#" class="form">
- <h1><b>Love Calculator</b></h1><hr/>
- <table border = "0">
- <tbody>
- <tr>
- <td><span class="style1"><img src="./img/male.png" width="50" height="50" style="margin-top: 15px;"/></span>
- <input size = "30" class="form-control" name = "per1" placeholder = "Enter Full Name" type="text" /><br/>
- <span class="style1"><img src="./img/female.png" width="50" height="50" /></span>
- <input size = "30" class="form-control" name = "per2" placeholder = "Enter Full Name" type="text" />
- </td>
- <td style = "background-image: url('img/heart_hands.gif');background-repeat:no-repeat; width: 220px; height: 128px;">
- <div id = "targetDiv" valign="middle" align = "center">0%</div>
- </td>
- </tr>
- </tbody>
- </table><br/>
- <input onclick = "updateDiv(per1.value, per2.value)" value = "Calculate" class="btn btn-default" type = "button">
- </form><br/>
- </div>
- </body>
- </html>
Comments
Add new comment
- Add new comment
- 3559 views