Salve a tutti,
ho un piccolo problemino con un form, quello che accade e' questo:
sto' cercando di metter su un questionario con una serie di radio button, ma con questo codice(*) i radio vengono visualizzati correttamente e cioe' viene settata come checked la prima risposta di OGNI domanda(cioe' quello che mi aspetto), mentre in questo codice(***)
viene mostrata checked solo l'ultima risposta.
per me sono identici, non so' per voi!
Grazie mille.
(*)
codice:<table align="center" width="90%" cellpadding="2" cellspacing="0" style="border: 1px solid black" border=1> <form name="sonda" method="get" action="./showdata.php"> <tr> <td colspan="2"> <h3>1. I understand something better after I</h3> <input type="Radio" name="response[0]" value="1" checked>try it out. <input type="Radio" name="response[0]" value="2">think it through. <input type="hidden" name="nr" value=""> <input type="hidden" name="id" value=""> </td> </tr> <tr> <td colspan="2"> <h3>2. I would rather be considered</h3> <input type="Radio" name="response[1]" value="1" checked>realistic. <input type="Radio" name="response[1]" value="2">innovative. <input type="hidden" name="nr" value=""> <input type="hidden" name="id" value=""> </td> </tr> <tr> <td colspan="2"> <h3>3. When I think about what I did yesterday, I am most likely to get</h3> <input type="Radio" name="response[2]" value="1" checked>a picture. <input type="Radio" name="response[2]" value="2">words. <input type="hidden" name="nr" value=""> <input type="hidden" name="id" value=""> </td> </tr> <tr> <td colspan="2"> <h3>4. I tend to</h3> <input type="Radio" name="response[3]" value="1" checked>understand details of a subject but may be fuzzy about its overall structure. <input type="Radio" name="response[3]" value="2">understand the overall structure but may be fuzzy about details. <input type="hidden" name="nr" value=""> <input type="hidden" name="id" value=""> </td> </tr> <tr> <td colspan="2"> <h3>5. When I am learning something new, it helps me to</h3> <input type="Radio" name="response[4]" value="1" checked>talk about it. <input type="Radio" name="response[4]" value="2">think about it. <input type="hidden" name="nr" value=""> <input type="hidden" name="id" value=""> </td> </tr> <tr> <td colspan="2"> <h3>6. If I were a teacher, I would rather teach a course</h3> <input type="Radio" name="response[5]" value="1" checked>that deals with facts and real life situations. <input type="Radio" name="response[5]" value="2">that deals with ideas and theories. <input type="hidden" name="nr" value=""> <input type="hidden" name="id" value=""> </td> </tr> <tr> <td colspan="2"> <h3>9. In a study group working on difficult material, I am more likely to</h3> <input type="Radio" name="response[8]" value="1" checked>jump in and contribute ideas. <input type="Radio" name="response[8]" value="2">sit back and listen. <input type="hidden" name="nr" value=""> <input type="hidden" name="id" value=""> </td> </tr> <tr> <td colspan="2"> <h3>10. I find it easier</h3> <input type="Radio" name="response[9]" value="1" checked>to learn facts. <input type="Radio" name="response[9]" value="2">to learn concepts. <input type="hidden" name="nr" value=""> <input type="hidden" name="id" value=""> </td> </tr> <tr> <td colspan="2"> <h3>11. In a book with lots of pictures and charts, I am likely to</h3> <input type="Radio" name="response[10]" value="1" checked>look over the pictures and charts carefully. <input type="Radio" name="response[10]" value="2">focus on the written text. <input type="hidden" name="nr" value=""> <input type="hidden" name="id" value=""> </td> </tr> <tr> <td colspan="2"> <h3>12. When I solve math problems</h3> <input type="Radio" name="response[11]" value="1" checked>I usually work my way to the solutions one step at a time. <input type="Radio" name="response[11]" value="2">I often just see the solutions but then have to struggle to figure out the steps to get to them. <input type="hidden" name="nr" value=""> <input type="hidden" name="id" value=""> </td> </tr> <tr> <td width="60" style="border-top: 1px solid black;" align="center"> <input type="submit" name="submit" value="Vota"> </td> </tr> </form> </table>
(***)
codice:echo "<table align=center width=90% cellpadding=2 cellspacing=0 style=\"border: 1px solid black\" border=1> "; echo "<form name=\"sonda\" method=\"get\" action=\"./showdata.php\"> "; while ($row = @mysql_fetch_array($query)) { $i=0; echo "<tr><td>"; while($i < $numrows) { if ($row[$i]!="") { //scrivo la domanda if ($i % 3 == 0) echo "".$row[$i]." "; else { //scrivo le risposte echo "<input type=\"Radio\" name=\"response[<?=$i%3;?>]\" value=1 checked> $row[$i] "; $i++; echo "<input type=\"Radio\" name=\"response[<?=$i%3;?>]\" value=2> $row[$i]"; echo "</td></tr>"; } } $i++; } } echo "<tr><td width=60 style=\"border-top: 1px solid black;\" align=center> <input type=\"submit\" name=\"submit\" value=\"Send\"> </td> </tr> </form></table> ";

Rispondi quotando