#1 by FEDx
Hi everyone, so I have a lottery in HTML (below the code). In the central column, I need to place a switch radio button with value=1,2,3,4,5 and so on. The problem is that (1) I cannot forloop because it would be three different variables, and I can't use the trick of running choices and labels. (2) I cannot apply Holt & Lory's code because the values have different and non-unitary distances. What can I do? I thought about creating individual radio buttons for each row, but how do I assign the value to have in the data when the player has made the switch? --- <style type="text/css"> .tg {border-collapse:collapse;border-spacing:0;} .tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px; overflow:hidden;padding:10px 5px;word-break:normal;} .tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px; font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;} .tg .tg-c3ow{border-color:inherit;text-align:center;vertical-align:top} .tg .tg-7btt{border-color:inherit;font-weight:bold;text-align:center;vertical-align:top} .tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top} </style> <table class="tg"> <thead> <tr> <th class="tg-7btt">50% of probability to get</th> <th class="tg-0pky"></th> <th class="tg-7btt"><span style="font-style:normal">50% of probability to get</span></th> </tr> </thead> <tbody> <tr> <td class="tg-c3ow">7€</td> <td class="tg-0pky"> </td> {{ endfor }} <td class="tg-c3ow">7€</td> </tr> <tr> <td class="tg-c3ow">8€</td> <td class="tg-0pky"> </td> {{ endfor }} <td class="tg-c3ow">6.3€</td> </tr> <tr> <td class="tg-c3ow">9€</td> <td class="tg-0pky"></td> <td class="tg-c3ow">5.8€</td> </tr> <tr> <td class="tg-c3ow">10€</td> <td class="tg-0pky"></td> <td class="tg-c3ow">5.4€</td> </tr> <tr> <td class="tg-c3ow">11€</td> <td class="tg-0pky"></td> <td class="tg-c3ow">5€</td> </tr> <tr> <td class="tg-c3ow">12€</td> <td class="tg-0pky"></td> <td class="tg-c3ow">4.5€</td> </tr> <tr> <td class="tg-c3ow">13€</td> <td class="tg-0pky"></td> <td class="tg-c3ow">3.8€</td> </tr> <tr> <td class="tg-c3ow">14€</td> <td class="tg-0pky"></td> <td class="tg-c3ow">2.7€</td> </tr> <tr> <td class="tg-c3ow">14.5€</td> <td class="tg-0pky"></td> <td class="tg-c3ow">1.5€</td> </tr> <tr> <td class="tg-c3ow">14.6€</td> <td class="tg-0pky"></td> <td class="tg-c3ow">0€</td> </tr> </tbody> </table> {{next_button}}
#2 by FEDx (edited )
Ok I solved it. This my solution: class Player(BasePlayer): switch = models.StringField(blank=True, choices=[['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', ''], ['8', ''], ['9', ''], ['10', '']], widget=widgets.RadioSelect) Then, in the table: <tr> <td class="tg-c3ow">7€</td> <td class="tg-0pky"> <label> <input type="radio" name="eg_switch" value="1" required/> </label> </td> <td class="tg-c3ow">7€</td> </tr> ... and so on <input type="submit" name="submit_button">