Originariamente inviata da lucavizzi
Se l'intenzione è quella di inviare i dati inseriti, non popolare il form con del testo, popolalo con degli input.
Ho cercato di trovare una soluzione implementando il seguente
codice:<%@ page language="java" contentType="text/html; charset=ISO-8859-1"adesso come potrei fare per recuperare tutti i valori immessi nella tabella? Sto invocando la mia servlet nell'action del form a cui vorrei passare tutto. Perchè non recupero nulla?codice:pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <form method="post" action="InsertDataUser?dati"> <table border='2' id='my_table' class='tabella' cellspacing='0' cellpadding='0'> <thead><tr><th>EMAIL </th><th>INDIRIZZO </th><th>NUMERO DI TELEFONO</th></tr></thead> <tbody> </tbody> </table><br/> <input type='button' value='Inserisci elementi' onClick="aggiungiRiga('my_table')"/> <input type=submit name="Insert" value='Approva i dati' onClick="createList()" > </form> </body> <script type='text/javascript'> function aggiungiRiga(id_table){ var table = document.getElementById(id_table); var tbody = table.getElementsByTagName('tbody')[0]; var colonne = table.getElementsByTagName('th').length; for(var i=0; i<colonne; i++){ var tr = document.createElement('tr'); var td = document.createElement('td'); var td1 = document.createElement('td'); var td2 = document.createElement('td'); var input = document.createElement("input"); var input1 = document.createElement("input"); var input2 = document.createElement("input"); input.type = "text";input.setAttribute("name","email"); input1.type = "text";input.setAttribute("name","indirizzo"); input2.type = "text";input.setAttribute("name","numero"); td.appendChild(input); td1.appendChild(input1); td2.appendChild(input2); tr.appendChild(td); tr.appendChild(td1); tr.appendChild(td2); } tbody.appendChild(tr); } </script> <script> function createList(){ var table = document.getElementById('my_table'); var dati = new Array(); //var amtLst = new Array(); for(var i=0; i<table.rows.length; i++){ var row = table.rows[i]; for(var j=0; j<row.cells.length; j++){ var cell = row.cells[0]; dati.push( cell.innerText ); } } return dati; } </script> </html>


Rispondi quotando