Before submission of form, use JS.
or
After submission,  allocate the time in the controller using *onvalidation*.  
See  
http://www.web2py.com/books/default/chapter/29/07/forms-and-validators#onvalidation

On Wednesday, 15 July 2020 13:58:28 UTC+1, mostwanted wrote:
>
> I thought it would be easy but its not, wrong values are being selected 
> from wrong lists! After submitting a form I wanna check to see if the 
> session field is either a single_session, double_session, 
> evening_single_session or evening_double_session, depending on what it is I 
> want time to be selected randomly from an appropriate list and inputted 
> into the session_time field but wrong values from wrong lists are entered, 
> information gets mixed up!
>
> model code:
> db.define_table('lecture',
>                 Field('subject_name', 'reference subject'),
>                 Field('department', 'reference departments'), #HERE
>                 Field('theLevels', label=SPAN('Levels'), requires=
> IS_IN_SET(['1.1', '1.2', '2.1', '2.2', '3.1', '3.2', '4.1', '4.2'], 
> zero='---Select 
> A Level---')), #HERE
>                 Field('lecturer', 'reference lecturer'),
>                 Field('class_session', requires=IS_IN_SET(['single 
> session', 'double session', 'evening single session', 'evening double 
> session'], zero='----Select A Session Period----')),
>                 Field('session_time', readable=False, writable=False),
>                 Field('class_room', readable=False, writable=False),
>                 Field('controller', readable=False, writable=False)
>                )
>
> single_session_times=['0830-0930hrs', '0930-1030hrs', '1100-1200',
> '1200-1300', '1400-1500', '1500-1600', '1600-1700']
> double_session_times=['0830-1030', '1100-1300', '1400-1700']
>
> evening_single_session_times=['1730-1830', '1830-1930']
> evening_double_session_times=['1730-1930']
> '''
> After submitting the form, have system scheck the session, if the session 
> is any of whats defined give it a proper time
> '''
> if db.lecture.class_session=='single session':
>     the_time=random.choice(single_session_times)
>     db.lecture.session_time.default=the_time
>
>     
> elif db.lecture.class_session=='evening single session':
>     the_time=random.choice(evening_single_session_times)
>     db.lecture.session_time.default=the_time
>
>     
> elif db.lecture.class_session=='double session':
>     the_time=random.choice(double_session_times)
>     db.lecture.session_time.default=the_time
>
>     
> elif db.lecture.class_session=='evening double session':
>     the_time=random.choice(evening_double_session_times)
>     db.lecture.session_time.default=the_time
>
>
>
> How can i achieve this with proper results from the intended list
>
> Mostwanted
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/701e166c-3d51-470b-ac59-9b2c3032ddbfo%40googlegroups.com.

Reply via email to