Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2.  
  3. <html>
  4.  
  5. <head>
  6.  
  7. <?php
  8.  
  9. // Login info and credentials
  10. $servername = "localhost";
  11. $username = "yy";
  12. $password = "xx";
  13. $dbname = "aa";
  14. $dbport = "3306";
  15.  
  16.  
  17. // Create connection
  18. $conn = new mysqli($servername, $username, $password, $dbname, $dbport);
  19. // Check connection
  20. if($conn->connect_error) {
  21. die("Connection failed: " . $conn->connect_error);
  22. }
  23. ?>
  24.  
  25. <script>
  26. function ShowComparison(str) {
  27. if (str=="") {
  28. document.getElementById("FormLocation").innerHTML="";
  29. return;
  30. } else {
  31. if (window.XMLHttpRequest) {
  32. // code for IE7+, Firefox, Chrome, Opera, Safari
  33. xmlhttp = new XMLHttpRequest();
  34. } else {
  35. // code for IE6, IE5
  36. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  37. }
  38. xmlhttp.onreadystatechange = function() {
  39. if (this.readyState == 4 && this.status == 200) {
  40. document.getElementById("FormLocation").innerHTML = this.responseText;
  41. }
  42. };
  43. xmlhttp.open("GET","form.php",true);
  44. xmlhttp.send();
  45. }
  46. }
  47. </script>
  48.  
  49. </head>
  50.  
  51. <body>
  52.  
  53. Load form:
  54.  
  55. <?php
  56. // Drop-down to load a form:
  57.  
  58. $sql_forms = "SELECT * from Forms";
  59. $result_forms = $conn->query($sql_forms);
  60.  
  61. echo "<select size='5' name='formnumber' onchange='ShowComparison(this.value)'>";
  62. while ($forms = mysqli_fetch_array($result_forms)) {
  63. echo "<option value='" .$forms['FormNumber']."'> ".$forms['FormName'] . "</option>";
  64. }
  65. echo "</select>";
  66. ?>
  67.  
  68. <br><br>
  69. <div id="FormLocation"/>
  70.  
  71. </body>
  72. </html>
  73.  
  74. <!DOCTYPE HTML>
  75.  
  76. <html>
  77.  
  78. <head>
  79. <link rel="stylesheet" type="text/css" href="showdownstyle.css"/>
  80.  
  81. <script>
  82. function CalculateScores() {
  83. var weight = document.querySelector('input[name="weight1"]:checked').value;
  84.  
  85. // Display the score
  86. document.getElementById("score").innerHTML = "Score: " + weight;
  87. }
  88. </script>
  89.  
  90. </head>
  91.  
  92. <body>
  93.  
  94. <div id="FormLocation"/>
  95.  
  96. <h1>Product comparison</h1>
  97. <div id="score">Calculation result here</div>
  98. <button onclick=CalculateScores()>Calculate</button>
  99.  
  100. <br><br>
  101.  
  102. <form
  103. id="ComparisonForm"
  104. action="form.php"
  105. name="ComparisonForm"
  106. method="POST"
  107. >
  108. <table class="comparison-table">
  109. <col width=15%>
  110. <col width=15%>
  111. <tr>
  112. <th class="headingleft">Criteria</th>
  113. <th class="headingcenter">Criteria weight</th>
  114. </tr>
  115.  
  116.  
  117. <tr>
  118. <td class="criteria"><input class="criteriainput" type="text" id="criteria1" name="criteria1"></td>
  119. <td class="weight">
  120. <li class="star-weight">
  121. <input type="radio" onclick="CalculateScores()" name="weight1" id="weight13" value="3"/><label for="weight13"></label>
  122. <input type="radio" onclick="CalculateScores()" name="weight1" id="weight12" value="2"/><label for="weight12"></label>
  123. <input type="radio" onclick="CalculateScores()" name="weight1" id="weight11" value="1" checked/><label for="weight11"></label>
  124. </li>
  125. </td>
  126. </tr>
  127. </table>
  128. </form>
  129.  
  130. </body>
  131. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement