Creating and displaying lists
Hi, I need to collect a list of student id numbers from one table so I can take this list, find them in another table, and display their names so their teachers can give them a score. I still like to use DTML but I do not know if I have the sequence-number in the proper format. This is what I have been playing with: <dtml-call "REQUEST.set('RECORD_ID', REQUEST.SESSION['RECORD_ID'])"> <dtml-in lookup_students_in_course> <dtml-call "REQUEST.set('student_id_temp', student_id)"> </dtml-in> <dtml-in expr="_.range(sequence-number)"> <dtml-call "REQUEST.set('student_id_temp', student_id_temp)"> <SELECT NAME="student_id_selected"> <option value=""></option> <dtml-in lookup_student_name sort=student_last_name> <OPTION VALUE="<dtml-var student_id>"> <dtml-var student_last_name>, <dtml-var student_first_name> </OPTION> </dtml-in> </SELECT> </dtml-in> I am having a hard time find reference material on this. Thanks, Larry
larrymcdonnell@att.net wrote:
Hi,
I need to collect a list of student id numbers from one table so I can take this list, find them in another table, and display their names so their teachers can give them a score.
I still like to use DTML but I do not know if I have the sequence-number in the proper format. This is what I have been playing with:
<dtml-call "REQUEST.set('RECORD_ID', REQUEST.SESSION['RECORD_ID'])"> <dtml-in lookup_students_in_course> <dtml-call "REQUEST.set('student_id_temp', student_id)"> </dtml-in> <dtml-in expr="_.range(sequence-number)"> <dtml-call "REQUEST.set('student_id_temp', student_id_temp)"> <SELECT NAME="student_id_selected"> <option value=""></option> <dtml-in lookup_student_name sort=student_last_name> <OPTION VALUE="<dtml-var student_id>"> <dtml-var student_last_name>, <dtml-var student_first_name> </OPTION> </dtml-in> </SELECT> </dtml-in>
I am having a hard time find reference material on this.
Thanks,
Larry
Larry, I have an idea for you. Rewrite in python. Its easy to return a html <select> structure from a python scripts and python scripts are so much easier to think thru than dtml. Then from your dtml (if i recall) you'd just <dtml-var expr="yourPython()">. From tal use include the "structure" key word like: <span tal:content="structure python:context.yourPython(params= ...) If you get stuck re-ask (but give your version in python code) :-) David
<snip> ----- Original Message ----- From: larrymcdonnell@att.net To: zope@zope.org Sent: Thursday, July 13, 2006 4:03 PM Subject: [Zope] Creating and displaying lists I need to collect a list of student id numbers from one table so I can take this list, find them in another table, and display their names so their teachers can give them a score. I still like to use DTML but I do not know if I have the sequence-number in the proper format. This is what I have been playing with: <dtml-call "REQUEST.set('RECORD_ID', REQUEST.SESSION['RECORD_ID'])"> <dtml-in lookup_students_in_course> <dtml-call "REQUEST.set('student_id_temp', student_id)"> </dtml-in> <dtml-in expr="_.range(sequence-number)"> <dtml-call "REQUEST.set('student_id_temp', student_id_temp)"> <SELECT NAME="student_id_selected"> <option value=""></option> <dtml-in lookup_student_name sort=student_last_name> <OPTION VALUE="<dtml-var student_id>"> <dtml-var student_last_name>, <dtml-var student_first_name> </OPTION> </dtml-in> </SELECT> </dtml-in> </snip> I think there is some confusion here. You should break this into 2 sections (and it would be much easier in a python script), but if you want to use dtml... The first section should build the list you are trying to display in the SELECT statement. It looks like you are trying to create a list of 'tuples' where each tuple consists of (id, lastname, firstname). I don't know where your data is coming from, but you could do something like: <dtml-call "REQUEST.set('studentList', [])"> # creates an empty list <in some loop> <dtml-call "studentList.append( (id, lastname, firstname) )"> # add one tuple (record) to the list <end of loop> After you have built your list test it by displaying it: <dtml-var studentList> to see if you have the right data in your list. You can then proceed to the next section where you are building your SELECT statements (warning: not tested and very ugly dtml) <select size="1" name="student_id_selected"> <dtml-in studentList> <option value="<dtml-var "_['sequence-item'][0]">" > <dtml-var "_['sequence-item'][1]">, <dtml-var "_['sequence-item'][2]"> </option> </dtml-in> </select> hth & Good Luck Jonathan
participants (3)
-
David H -
Jonathan -
larrymcdonnell@att.net