Eureka2.0 - 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 Eureka2.0.php

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