Hi, I am trying to create five list to collect student scores. As you can see I am using simple html to create them. 1) <SELECT NAME="student_score1_temp"> <option value=""></option> <OPTION VALUE="0">0 <OPTION VALUE="2">1 <OPTION VALUE="3">2 <OPTION VALUE="3">3 <OPTION VALUE="4">4 <OPTION VALUE="5">5 <OPTION VALUE="6">6 </OPTION> </SELECT> 2) <SELECT NAME="student_score2_temp"> <option value=""></option> <OPTION VALUE="0">0 <OPTION VALUE="2">1 <OPTION VALUE="3">2 <OPTION VALUE="3">3 <OPTION VALUE="4">4 <OPTION VALUE="5">5 <OPTION VALUE="6">6 </OPTION> </SELECT> . . 5) <SELECT NAME="student_score5_temp"> <option value=""></option> <OPTION VALUE="0">0 <OPTION VALUE="2">1 <OPTION VALUE="3">2 <OPTION VALUE="3">3 <OPTION VALUE="4">4 <OPTION VALUE="5">5 <OPTION VALUE="6">6 </OPTION> </SELECT> I use the the following dtml commands to populate the db. <dtml-call "REQUEST.set('counter', REQUEST.SESSION['counter'])"> <dtml-call "REQUEST.set('loop_counter_temp', '0')"> <dtml-call "string_to_int(loop_counter_temp ,REQUEST)"> <dtml-call "REQUEST.set('loop_counter', y)"> <dtml-call "REQUEST.set('loop_counter', 1)"> <dtml-in expr="_.range(counter)"> <dtml-call "REQUEST.set('student_score1', student_score1_temp[loop_counter])"> <dtml-call "REQUEST.set('student_score2', student_score2_temp[loop_counter])"> <dtml-call "REQUEST.set('student_score3', student_score3_temp[loop_counter])"> <dtml-call "REQUEST.set('student_score4', student_score4_temp[loop_counter])"> <dtml-call "REQUEST.set('student_score5', student_score5_temp[loop_counter])"> </dtml-in> <dtml-call expr="create_holistic_score_record(REQUEST)"> But these are the results: REQUEST form student_score1_temp ['2', '2', '2', '2', '2', '2', '2', '2'] Submit 'Submit' student_score2_temp ['3', '3', '3', '3', '3', '3', '3', '3'] student_score3_temp ['3', '3', '3', '3', '3', '3', '3', '3'] student_score4_temp ['4', '4', '4', '4', '4', '4', '4', '4'] student_score5_temp ['5', '5', '5', '5', '5', '5', '5', '5'] Any ideas where I am going wrong. Thanks, Larry McDonnell
----- Original Message ----- From: larrymcdonnell@att.net To: zope@zope.org Sent: Tuesday, September 05, 2006 1:30 PM Subject: [Zope] Problems with lists I use the the following dtml commands to populate the db. <snip> <dtml-call "REQUEST.set('counter', REQUEST.SESSION['counter'])"> <dtml-call "REQUEST.set('loop_counter_temp', '0')"> <dtml-call "string_to_int(loop_counter_temp ,REQUEST)"> <dtml-call "REQUEST.set('loop_counter', y)"> <dtml-call "REQUEST.set('loop_counter', 1)"> <dtml-in expr="_.range(counter)"> <dtml-call "REQUEST.set('student_score1', student_score1_temp[loop_counter])"> <dtml-call "REQUEST.set('student_score2', student_score2_temp[loop_counter])"> <dtml-call "REQUEST.set('student_score3', student_score3_temp[loop_counter])"> <dtml-call "REQUEST.set('student_score4', student_score4_temp[loop_counter])"> <dtml-call "REQUEST.set('student_score5', student_score5_temp[loop_counter])"> </dtml-in> <dtml-call expr="create_holistic_score_record(REQUEST)"> But these are the results: REQUEST form student_score1_temp ['2', '2', '2', '2', '2', '2', '2', '2'] Submit 'Submit' student_score2_temp ['3', '3', '3', '3', '3', '3', '3', '3'] student_score3_temp ['3', '3', '3', '3', '3', '3', '3', '3'] student_score4_temp ['4', '4', '4', '4', '4', '4', '4', '4'] student_score5_temp ['5', '5', '5', '5', '5', '5', '5', '5'] </snip> I can't figure out what your dtml prior to the loop is trying to accomplish, however inside the loop your 'loop_counter' variable is a constant value (it does not change, so you keep referring to the same list element). You need something like: <dtml-in expr="_.range(counter)"> <dtml-call "REQUEST.set('student_score1', student_score1_temp[_['sequence-item']])"> The _['sequence-item'] will contain the current iteration result of your _.range(counter) statement. Better yet, do this in a python script (way easier). hth Jonathan
participants (2)
-
Jonathan -
larrymcdonnell@att.net