vi allego il codice:
in pratica vorrei inserire in automatico nel form i campi incollati nel TextArea, avendo una struttura sempre omogenea. Sarebbe possibile?Codice PHP:
<!DOCTYPE html><html lang="it"> <head> <meta charset="UTF-8"> <title>TAB GUASTI: Metroweb POLO MI-TO-BO</title> <style> *{ font-family: arial; font-size: 11px; } table{ border-collapse: collapse; border: 1px solid silver; } tr{ border-bottom: 1px solid silver; } /*This will style the header row!*/ tr:first-child td { background-color: #EEE; border: 1px solid silver; font-weight: bold; padding: 2px; text-align: center; } div { clear:both; } label { width:200px; float:left; } input { width:200px; float:left; } #invia { clear:both; } </style> <script language="javascript"> function createTable() { // Get the data var excelData = document.getElementById('csv').value; // split into rows excelRow = excelData.split(String.fromCharCode(10)); // split rows into columns for (i=0; i<excelRow.length; i++) { excelRow[i] = excelRow[i].split(String.fromCharCode(9)); } // start to create the HTML table var myTable = document.createElement("table"); var myTbody = document.createElement("tbody"); // Loop over the rows for (i=0; i<excelRow.length - 1; i++) { // create a row in the HTML table var myRow = document.createElement("tr"); // Loop over the columns and add TD to the TR for (j=0; j<excelRow[i].length; j++) { // Loop over the row columns if (excelRow[i][j].length != 0) { var myCell = document.createElement("td"); myCell.innerHTML = excelRow[i][j]; } myRow.appendChild(myCell); } myTbody.appendChild(myRow); } myTable.appendChild(myTbody); document.body.appendChild(myTable); // console.log(myTable) } </script> </head> <body> <div> <div>Per facilitare l'inserimento dei guasti metroweb incolla il contenuto delle celle di remedy qui!.</div> <textarea id="csv" placeholder="Paste XLSX content here" style="width: 300px; height: 100px;"></textarea><br/> <input type="button" value="Create HTML Table from XLSX content" onclick="createTable()" > </div> <div> <form action="insert.php" method="post"> <fieldset> <div> <label for="idrichiesta">ID_Richiesta:</label> <input type="text" name="idrichiesta" id="idrichiesta"> </div> <div> <label for="lastName">Codice Comunicazione OLO:</label> <input type="text" name="CCOLO" id="CCOLO"> </div> <div> <label for="lastName">Nome System:</label> <select name="system"> <option value="Soleto">Soleto</option> <option value="Sertori">Sertori</option> <option value="Valtellina">Valtellina</option> </select> </div> <div> <label for="idrichiesta">Stato Attuale:</label> <select name="statoattuale"> <option value="In verifica">In verifica</option> <option value="In Lavorazione">In Lavorazione</option> <option value="Sospeso">Sospeso</option> <option value="Chiuso">Chiuso</option> </select> </div> <div> <label for="lastName">ID Risorsa:</label> <input type="text" name="idrisorsa" id="idrisorsa"> </div> <div> <label for="lastName">Cognome Cliente:</label> <input type="text" name="cliente" id="cliente"> </div> <div> <label for="idrichiesta">Flag Individuazione Guasto:</label> <select name="flag"> <option value="Verticale">Verticale</option> <option value="Orizzontale">Orizzontale</option> </select> </div> <div> <label for="lastName">Comune:</label> <select name="comune"> <option value="MILANO">MILANO</option> <option value="BOLOGNA">BOLOGNA</option> <option value="BOLOGNA">TORINO</option> </select> </div> <div> <label for="idrichiesta">GPON ID:</label> <input type="text" name="gpon" id="gpon"> </div> <div> <label for="lastName">Data Creazione:</label> <input type="datetime-local" name="datacreazione" id="datacreazione"> </div> <div> <label for="lastName">Data 1°sospensione:</label> <input type="datetime-local" name="1sospensione" id="1sospensione"> </div> <div> <label for="lastName">Data 1°de-sospensione:</label> <input type="datetime-local" name="1desospensione" id="1desospensione"> </div> <div> <label for="lastName">Data 2°sospensione:</label> <input type="datetime-local" name="2sospensione" id="2sospensione"> </div> <div> <label for="lastName">Data 2°de-sospensione:</label> <input type="datetime-local" name="2desospensione" id="2desospensione"> </div> <div> <label for="lastName">Data 3°sospensione:</label> <input type="datetime-local" name="3sospensione" id="3sospensione"> </div> <div> <label for="lastName">Data 3°de-sospensione:</label> <input type="datetime-local" name="3desospensione" id="3desospensione"> </div> <div> <label for="lastName">Data Chiusura:</label> <input type="datetime-local" name="datachiusura" id="datachiusura"> </div> <div> <label </label> <input type="submit" id="invia" value="INVIA"> </div> </fieldset> </form> </div> </body></html>