Is there any way to use radio buttons generated dynamically as a result of a ZSQL method. Each iteration needs to have a different name if they are to be treated as a separate group. The problem is compounded by the fact that I must write the user's choices to a database. Here is the code I have so far: <form action=formhandlerinputresults> <table border=1> <tr><th>Name</th><th>Exam Grade</th><th>Term Grade</th></tr> <dtml-in getclassmembers> <input type=hidden name=result.studentid:records value=<dtml-var studentid>> <input type=hidden name=result.classid:records value=<dtml-var teacherid>> <tr><td><dtml-var firstname> <dtml-var surname></td> <td><input type =radio name=result.mark:records value="A">A <input type =radio name=result.mark:records value="B">B <input type =radio name=result.mark:records value="C">C <input type =radio name=result.mark:records value="D">D <input type =radio name=result.mark:records value="E">E <input type =radio name=result.mark:records value="F">F </td><td><input type =radio name=result.termmark:records value="A">A <input type =radio name=result.termmark:records value="B">B <input type =radio name=result.termmark:records value="C">C <input type =radio name=result.termmark:records value="D">D <input type =radio name=result.termmark:records value="E">E <input type =radio name=result.termmark:records value="F">F </td></tr></dtml-in></table> <br><br> <input type=submit value="Enter Results"> I could use checkboxes but I want to prevent multiple selections regards garry
From: "garry saddington" <garry@joydiv.fsnet.co.uk>
Is there any way to use radio buttons generated dynamically as a result of a ZSQL method. Each iteration needs to have a different name if they are to be treated as a separate group. The problem is compounded by the fact that I must write the user's choices to a database. Here is the code I have so far:
<form action=formhandlerinputresults> <table border=1> <tr><th>Name</th><th>Exam Grade</th><th>Term Grade</th></tr> <dtml-in getclassmembers> <input type=hidden name=result.studentid:records value=<dtml-var studentid>> <input type=hidden name=result.classid:records value=<dtml-var teacherid>> <tr><td><dtml-var firstname> <dtml-var surname></td> <td><input type =radio name=result.mark:records value="A">A <input type =radio name=result.mark:records value="B">B <input type =radio name=result.mark:records value="C">C <input type =radio name=result.mark:records value="D">D <input type =radio name=result.mark:records value="E">E <input type =radio name=result.mark:records value="F">F </td><td><input type =radio name=result.termmark:records value="A">A <input type =radio name=result.termmark:records value="B">B <input type =radio name=result.termmark:records value="C">C <input type =radio name=result.termmark:records value="D">D <input type =radio name=result.termmark:records value="E">E <input type =radio name=result.termmark:records value="F">F </td></tr></dtml-in></table> <br><br>
<input type=submit value="Enter Results">
I am not quite sure what you are looking for, but you want to have a different radio button 'name' for each iteration thru the dtml-in loop you could use the 'sequence-index' or 'sequence-number' loop variables. eg. <input type =radio name=<dtml-var sequence-index>:records value="A">B <input type =radio name=<dtml-var sequence-index>:records value="B">B <input type =radio name=<dtml-var sequence-index>:records value="C">B <input type =radio name=<dtml-var sequence-index>:records value="D">B <input type =radio name=<dtml-var sequence-index>:records value="E">B <input type =radio name=<dtml-var sequence-index>:records value="F">B This will give you a set of radio buttons (labelled 0-n, where n is the number of dtml-in loop iterations - 1) that have the same name for any given loop iteration, but will change from one loop iteration to the next. (sequence-number counts from 1 instead of from 0). HTH Jonathan
I am not quite sure what you are looking for, but you want to have a different radio button 'name' for each iteration thru the dtml-in loop you could use the 'sequence-index' or 'sequence-number' loop variables.
eg.
<input type =radio name=<dtml-var sequence-index>:records value="A">B <input type =radio name=<dtml-var sequence-index>:records value="B">B <input type =radio name=<dtml-var sequence-index>:records value="C">B <input type =radio name=<dtml-var sequence-index>:records value="D">B <input type =radio name=<dtml-var sequence-index>:records value="E">B <input type =radio name=<dtml-var sequence-index>:records value="F">B
This will give you a set of radio buttons (labelled 0-n, where n is the number of dtml-in loop iterations - 1) that have the same name for any given loop iteration, but will change from one loop iteration to the next. (sequence-number counts from 1 instead of from 0).
HTH
Jonathan
Thanks, this is getting nearer but how could i then iterate over <dtml-var sequence-index> in the ZSQL method that writes to the database? regards garry
----- Original Message ----- From: "garry saddington" <garry@joydiv.fsnet.co.uk> To: <zope@zope.org> Sent: Saturday, October 02, 2004 11:56 AM Subject: Re: [Zope] dynamic radio buttons
I am not quite sure what you are looking for, but you want to have a different radio button 'name' for each iteration thru the dtml-in loop
you
could use the 'sequence-index' or 'sequence-number' loop variables.
eg.
<input type =radio name=<dtml-var sequence-index>:records value="A">B <input type =radio name=<dtml-var sequence-index>:records value="B">B <input type =radio name=<dtml-var sequence-index>:records value="C">B <input type =radio name=<dtml-var sequence-index>:records value="D">B <input type =radio name=<dtml-var sequence-index>:records value="E">B <input type =radio name=<dtml-var sequence-index>:records value="F">B
This will give you a set of radio buttons (labelled 0-n, where n is the number of dtml-in loop iterations - 1) that have the same name for any given loop iteration, but will change from one loop iteration to the next. (sequence-number counts from 1 instead of from 0).
HTH
Jonathan
Thanks, this is getting nearer but how could i then iterate over <dtml-var sequence-index> in the ZSQL method that writes to the database? regards garry ___________
Garry, You should call an intermediary script that will call zSQL. Just repeat <dtml-in getclassmembers> there as well and match sequence-numbers , eg mark = REQUEST.get('mark' + str(sequence-number)) termark = REQUEST.get('termark' + str(sequence-number)) Now you can call zsql like zUpdate(studentID, mark,termark) ; Sorry for the ugly pseudo code. David ____________________________________
Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
On Saturday 02 October 2004 20:24, David Hassalevris wrote:
----- Original Message ----- From: "garry saddington" <garry@joydiv.fsnet.co.uk> To: <zope@zope.org> Sent: Saturday, October 02, 2004 11:56 AM Subject: Re: [Zope] dynamic radio buttons
I am not quite sure what you are looking for, but you want to have a different radio button 'name' for each iteration thru the dtml-in loop
you
could use the 'sequence-index' or 'sequence-number' loop variables.
eg.
<input type =radio name=<dtml-var sequence-index>:records
value="A">B
<input type =radio name=<dtml-var sequence-index>:records
value="B">B
<input type =radio name=<dtml-var sequence-index>:records
value="C">B
<input type =radio name=<dtml-var sequence-index>:records
value="D">B
<input type =radio name=<dtml-var sequence-index>:records
value="E">B
<input type =radio name=<dtml-var sequence-index>:records
value="F">B
This will give you a set of radio buttons (labelled 0-n, where n is the number of dtml-in loop iterations - 1) that have the same name for any given loop iteration, but will change from one loop iteration to the
next.
(sequence-number counts from 1 instead of from 0).
HTH
Jonathan
Thanks, this is getting nearer but how could i then iterate over <dtml-var sequence-index> in the ZSQL method that writes to the database? regards garry ___________
Garry,
You should call an intermediary script that will call zSQL. Just repeat <dtml-in getclassmembers> there as well and match sequence-numbers , eg mark = REQUEST.get('mark' + str(sequence-number)) termark = REQUEST.get('termark' + str(sequence-number))
Now you can call zsql like zUpdate(studentID, mark,termark) ; Sorry for the ugly pseudo code.
David This looks good, thanks. regards garry
----- Original Message ----- From: "garry saddington" <garry@joydiv.fsnet.co.uk> To: <zope@zope.org> Sent: Saturday, October 02, 2004 12:52 PM Subject: Re: [Zope] dynamic radio buttons
On Saturday 02 October 2004 20:24, David Hassalevris wrote:
----- Original Message ----- From: "garry saddington" <garry@joydiv.fsnet.co.uk> To: <zope@zope.org> Sent: Saturday, October 02, 2004 11:56 AM Subject: Re: [Zope] dynamic radio buttons
I am not quite sure what you are looking for, but you want to have a different radio button 'name' for each iteration thru the dtml-in loop
you
could use the 'sequence-index' or 'sequence-number' loop variables.
eg.
<input type =radio name=<dtml-var sequence-index>:records
value="A">B
<input type =radio name=<dtml-var sequence-index>:records
value="B">B
<input type =radio name=<dtml-var sequence-index>:records
value="C">B
<input type =radio name=<dtml-var sequence-index>:records
value="D">B
<input type =radio name=<dtml-var sequence-index>:records
value="E">B
<input type =radio name=<dtml-var sequence-index>:records
value="F">B
This will give you a set of radio buttons (labelled 0-n, where n is the number of dtml-in loop iterations - 1) that have the same name for any given loop iteration, but will change from one loop iteration to the
next.
(sequence-number counts from 1 instead of from 0).
HTH
Jonathan
Thanks, this is getting nearer but how could i then iterate over <dtml-var sequence-index> in the ZSQL method that writes to the database? regards garry ___________
Garry,
You should call an intermediary script that will call zSQL. Just repeat <dtml-in getclassmembers> there as well and match sequence-numbers , eg mark = REQUEST.get('mark' + str(sequence-number)) termark = REQUEST.get('termark' + str(sequence-number))
Now you can call zsql like zUpdate(studentID, mark,termark) ; Sorry for the ugly pseudo code.
David This looks good, thanks. regards garry
Garry, It occurs to me that this might become disasterous if someone adds a new record in the time between form input and zsql calls using sequence numbers (that would throw your "alignment" off). I would replace sequence generated names, eg 'mark' + str(sequence_number) wth mark + '-' + str(StudentID) Then with <dtml-in getClassMembers> would could test the REQUEST for 'mark-' + str(StudentID). If its not in the REQUEST its because a new record was added into ClassMembers. David
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
David Hassalevris -
garry saddington -
Jonathan Hobbs