Eureka - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of Eureka.php

  1. <button onclick="copyTemplate()">Copy Template</button>
  2.  
  3. <script>
  4. function copyTemplate() {
  5.   // Get the template element (which contains the table and associated elements and functions)
  6.   var template = document.getElementById("template");
  7.  
  8.   // Clone the template element and its contents
  9.   var copiedTemplate = template.cloneNode(true);
  10.  
  11.   // Give the cloned template element a unique id
  12.   copiedTemplate.id = "copiedTemplate";
  13.  
  14.   // Clear the user input fields in the copied template
  15.   // Only clear the fillable and content editable fields, not the orange bar field
  16.   var inputElements = copiedTemplate.querySelectorAll(".field");
  17.   var contentEditable = copiedTemplate.querySelector("#contenteditable");
  18.   for (var i = 0; i < inputElements.length; i++) {
  19.     inputElements[i].value = "";
  20.   }
  21.   contentEditable.innerHTML = "";
  22.  
  23. // Clear the user input areas in tables 3 and 4
  24. var table3InputElements = copiedTemplate.querySelectorAll("#table3 input");
  25. for (var i = 0; i < table3InputElements.length; i++) {
  26.   table3InputElements[i].value = "";
  27. }
  28.  
  29. var table4InputElements = copiedTemplate.querySelectorAll("#table4 div[contenteditable=true]");
  30. for (var i = 0; i < table4InputElements.length; i++) {
  31.   table4InputElements[i].innerHTML = "";
  32. }
  33.   // Append the cloned template element to the document body
  34.   document.body.appendChild(copiedTemplate);
  35.  
  36.   // Get the table element from the copied template
  37.   var table = copiedTemplate.querySelector("table");
  38.  
  39.   // Give the table a unique id
  40.   table.id = "copiedTable";
  41.  
  42.   // Create a new element to hold the "add row" button and its associated function
  43.   /*
  44.   var addRowButtonContainer = document.createElement("div");
  45.  
  46.   // Add the "add row" button to the container element
  47.   
  48.   var addRowButton = document.createElement("button");
  49.   addRowButton.innerHTML = "Add Row";
  50.   addRowButton.onclick = function() {
  51.     // Add a new row to the table
  52.     var row = document.getElementById("copiedTable").insertRow(-1); 
  53.     var cell1 = row.insertCell(0);
  54.     var cell2 = row.insertCell(1);
  55.     var cell3 = row.insertCell(2);
  56.     cell1.innerHTML = "<input class='field' type='text' placeholder='Enter Filename' style='width: 430px'>";
  57.     cell2.innerHTML = "<input class='field' type='text' placeholder='Enter Graphic Description' style='width: 430px'>";
  58.     cell3.innerHTML = "<input class='field' type='text' placeholder='Enter Alt Text/Title Tag' style='width: 430px'>";
  59.   }
  60.  
  61.   // Append the button to the container element
  62.   addRowButtonContainer.appendChild(addRowButton);
  63.   
  64.   // Create a new element to hold the "toggle table" button and its associated function
  65.   var toggleTableButtonContainer = document.createElement("div");
  66.  
  67.   // Add the "toggle table" button to the container element
  68.   var toggleTableButton = document.createElement("button");
  69.   toggleTableButton.innerHTML = "Toggle Table";
  70.   toggleTableButton.onclick = function() {
  71.     // Toggle the display style of the table
  72.     var table = document.getElementById("copiedTable");
  73.     if (table.style.display === "none") {
  74.       table.style.display = "table";
  75.     } else {
  76.       table.style.display = "none";
  77.     }
  78.   }
  79.  
  80.   // Append the button to the container element
  81.   toggleTableButtonContainer.appendChild(toggleTableButton);
  82.  
  83.   // Append the button container elements to the copied template element
  84.   copiedTemplate.appendChild(addRowButtonContainer);
  85.   copiedTemplate.appendChild(toggleTableButtonContainer);
  86.   */
  87. }
  88. </script>
  89.  
  90. <div id="template">
  91. </script>
  92.  
  93.  
  94.   
  95.     <style>
  96.       table {
  97.         width: 70%;
  98.       }
  99.     </style>
  100.     
  101. <table id="table1">
  102. <tr style="background-color: gray;">
  103.   <td>Page <input type="number"></td>
  104.   <td>Screen <input type="number"></td>
  105. </tr>
  106. <tr style="background-color: orange;">
  107.   <td colspan="2"><input type="text" style="width: 500px;">
  108.   </td>
  109.   </tr>
  110.   <tr>
  111.   <td colspan="2">
  112.   <div id="contenteditable" contenteditable=""></div>
  113.   </td>
  114.     </tr>
  115.     <tr>
  116.   <td colspan="2" style="text-align: center;">Select Navigate to Continue</td>
  117.  
  118. </tr>
  119. <tr style="background-color: gray;">
  120. <td colspan="2" style="text-align: center;">Navigation Bar</td>
  121. </tr>
  122.  
  123.  
  124. <table id="myTable" style="table-layout: fixed; resize: both;">
  125.   <tbody>
  126. <tr style="background-color: gray;">
  127. <th style="width: 430px">Filename</th>
  128. <th style="width: 430px">Graphic Description</th>
  129. <th style="width: 430px">Alt Text/Title Tag</th>
  130. </tr>
  131. <tr>
  132. <td><input class="field" type="text" placeholder="Enter Filename" style="width: 430px"></td>
  133. <td><input class="field" type="text" placeholder="Enter Graphic Description" style="width: 430px"></td>
  134. <td><input class="field" type="text" placeholder="Enter Alt Text/Title Tag" style="width: 430px"></td>
  135. </tr>
  136.  
  137.  
  138. <button onclick="addRow(this)">Add Row</button>
  139. <button onclick="toggleTable(this)">Toggle Table</button>
  140.  
  141. </tbody>
  142.  
  143. <script>
  144.  
  145. function addRow(e) {
  146.  
  147. var table = e.parentNode.querySelector("#myTable");
  148. console.log(table);
  149. var row = table.insertRow(-1); // Insert a new row at the end of the table
  150. var cell1 = row.insertCell(0);
  151. var cell2 = row.insertCell(1);
  152. var cell3 = row.insertCell(2);
  153. cell1.innerHTML = "<input class='field' type='text' placeholder='Enter Filename' style='width: 430px'>";
  154. cell2.innerHTML = "<input class='field' type='text' placeholder='Enter Graphic Description' style='width: 430px'>";
  155. cell3.innerHTML = "<input class='field' type='text' placeholder='Enter Alt Text/Title Tag' style='width: 430px'>";
  156. }
  157.  
  158. function toggleTable(e) {
  159. var fields = document.getElementsByClassName("field");
  160. var table = e.parentNode.querySelector("#myTable");
  161. console.log(table);
  162. // If the table is collapsed, expand it
  163. if (table.open === false) {
  164. for (var i = 0; i < fields.length; i++) {
  165. fields[i].style.display = "block";
  166. }
  167. table.open = true;
  168. } else {
  169. // Otherwise, collapse it
  170. for (var i = 0; i < fields.length; i++) {
  171. fields[i].style.display = "none";
  172. }
  173. table.open = false;
  174. }
  175. }
  176.  
  177. </script>
  178.  
  179.  
  180.  
  181. <table id="table3">
  182. <tbody>
  183. <tr style="background-color: gray;">
  184. <td>Programming</td>
  185. </tr>
  186. <tr>
  187. <td colspan="2"><textarea style="width:100%; height:100%;"></textarea></td>
  188. </tr>
  189.  
  190.  
  191.  
  192. <table id="table4">
  193. <tbody>
  194. <tr style="background-color: lightblue;">
  195. <th>Narrated Text</th>
  196. <th>Graphics</th>
  197. </tr>
  198. <tr>
  199. <td style="width: 50%;">
  200. <div contenteditable="true" class="editable-area"></div>
  201. </td>
  202. <td style="width: 20%;">
  203. <div contenteditable="true" class="editable-area"></div>
  204. </td>
  205. </tr>
  206. <style>
  207. .editable-area {
  208. white-space: pre-line;
  209. overflow-wrap: break-word;
  210. min-height: 100px;
  211. max-height: 100px;
  212. resize: vertical;
  213. }
  214. </style>
  215. </tbody>
  216. </table>
  217. </div>
  218.  
File Description
  • Eureka
  • PHP Code
  • 19 Dec-2022
  • 6.37 Kb
You can Share it: