Ciao a tutti!
Vorrei creare un form nel quale ci sono dei campi da compilare, altri da selezionare tra le opzioni proposte, ecc.
Una volta compilato vorrei creare un Report (tutto in locale, niente invio a email o a siti) con i dati immessi, con un bottone per la Stampa della pagina.
SOLUZIONE 1
Una soluzione quasi perfetta l'avevo trovata qui:
http://forum.html.it/forum/showthrea...2#post11918392
Il report creato è proprio il risultato finale che mi servirebbe!
Ecco l'esempio pratico -> LINK (compilate il form ed avrete il report che vorrei ottenere io).
Ho provato a modificarlo inserendo i "checkbox" o i "radio", ma il problema è che nel report finale mi riporta tutte le scelte, non solo quella selezionata!
Se metto ad esempio:
Codice PHP:
<form name="WapForm">
Nome: <input type="text" name="Quiz.UserData.Nome" size=20>
</p>
Cognome: <input type="text" name="Quiz.UserData.Cognome" size=20>
</p>
Risposta: Sì<input type="radio" name="Quiz.UserData.Risposta" value="S">
No<input type="radio" name="Quiz.UserData.Risposta" value="N">
</p>
nel report mi riporta entrambi i valori:
Risposta: S
Risposta: N
Questo perché prende come nome da inserire nel Report tutto quello che c'è scritto dopo il valore Quiz.UserData.
Quindi se trova due valori con lo stesso nome li riporta entrambi, non solo quello selezionato.
Sicuramente sono niubbo io, ma non sono riuscito a sistemarli! 
SOLUZIONE 2
La seconda soluzione che ho trovato è questa -> LINK
Qui i risultati del form vengono visualizzati in una casella di testo (compilate il form e potete vedere il risultato).
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en">
<head>
<title>JavaScript - Example form</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
<!--
// This is the check script
function checkit()
{
// In textstring I gather the data that are finally written to the textarea.
var textstring = '';
// First of all, have all the text boxes been filled in?
// This part is treated in the normal page.
// I put all boxes and their values in textstring
for (i=0;i<4;i++) {
var box = document.forms['example'].elements[i];
if (!box.value) {
alert('You haven\'t filled in ' + box.name + '!');
box.focus()
return;
}
textstring += box.name + ': ' + box.value + '\n';
}
// Get value of the 'Why' radio buttons.
user_input = '';
for (i=0;i<document.forms['example'].why.length;i++) {
if (document.forms['example'].why[i].checked) {
user_input = document.forms['example'].why[i].value;
}
}
textstring += 'Why: ' + user_input + '\n';
// Get value of the 'How' select box.
user_input = document.example.refer.options[document.example.refer.selectedIndex].value
textstring += 'How: ' + user_input + '\n';
// See what checkboxes are checked. They are elements 9-12
textstring += 'More info: ';
for (i=9;i<13;i++) {
if (document.example.elements[i].checked) {
textstring += document.example.elements[i].name + ' ';
}
}
// Write textstring to the textarea.
document.forms['example'].output.value = textstring;
}
// -->
</script>
<style type="text/css">
td[colspan] {
text-align: center;
}
</style>
<link rel="stylesheet" href="../quirksmode.css" />
<link rel="up" href="contents.html" />
<link rel="intro" href="forms.html" />
<script type="text/javascript" src="../quirksmode.js"></script>
</head>
<body>
<form name="example" action="#" onsubmit="checkit(); return false">
<table class="form">
<tr>
<td>Name</td>
<td><input name="name" /></td>
</tr>
<tr>
<td>Address</td>
<td><input name="address" /></td>
</tr>
<tr>
<td>City</td>
<td><input name="City" /></td>
</tr>
<tr>
<td>E-mail</td>
<td><input name="E-mail" /></td>
</tr>
<tr>
<td>Why do you want to learn JavaScript?</td>
<td><input type="radio" name="why" value="Dunno" />Dunno
<input type="radio" name="why" value="Boss" />Because my boss told me to
<input type="radio" name="why" value="Interest" />Generally interested
<input type="radio" name="why" value="Useful" />It might come in useful
</td></tr>
<tr>
<td>How did you get to this site?</td>
<td><select name="refer">
<option value='' selected="selected">--- Select ---</option>
<option value="random">I found it by accident</option>
<option value="wdf">Through WDF</option>
<option value="NetlinQ">Through NetlinQ</option>
<option value="searchengine">Through a search engine</option>
</select>
</td></tr>
<tr>
<td>I'd like additional information about</td>
<td><input type="checkbox" name="oranges" />oranges
<input type="checkbox" name="potatoes" />potatoes
<input type="checkbox" name="tomatoes" />tomatoes
<input type="checkbox" name="blue whales" />blue whales</td>
</tr>
<tr><td colspan="2"><input type="submit" value="Submit form" />
<input type="reset" /></td></tr>
<tr><td colspan="2"><textarea cols="30" rows="7" name="output">When you hit 'Submit' the user input will be written to this textarea</textarea></td></tr>
</table>
</form>
</body>
</html>
Qualcuno mi sa dire se è possibile inserire "checkbox" o "radio" nella soluzione 1 e far comparire nel report solo i valori selezionati?
Se non è possibile fare così, ci sarebbe un modo per creare un report in un'altra pagina da stampare (come quello della soluzione 1), partendo dal form della soluzione 2?
Spero di essermi spiegato
e che possiate darmi una mano!
Grazie a tutti per l'aiuto!