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