Salve a tutti sono nuovo e avrei bisogno di un aiuto.
Allora ho un form (dinamico per così dire, creato da script js) su cui è definita una tabella (3colonne). Una volta che l'utente sottoscrive questo form e fa il submit vorrei che una servlet recuperasse questi dati, per poi poterli inserire in db Mysql. Bene come faccio per intanto a recuperare questi dati da servlet. Vi posto il codice della jsp dove ho tutto, putroppo l'array che passo non contiene nulla di quello che è stato digitato.
Se avete altre idee in merito,su come recuperare i valori dei campi, consigliatemi. Vi ringrazio!
Grazie a chi si interesserà.
codice:<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>codice:<!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; var tr = document.createElement('tr'); for(var i=0; i<colonne; i++){ var td = document.createElement('td'); var tx = document.createTextNode(prompt("Inserisci testo per cella "+(i+1),"")); td.appendChild(tx); tr.appendChild(td); } 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[j]; dati.push( cell.innerText ); } } return dati; } </script> </html>

Rispondi quotando


