Thanks yuan. i finally got it . I think i'll be much happier and productive with ZPTs. In the body tag define: <body tal:define="doDistrict request/districtname|nothing"> this was for 1st dropdown list ; <select name=districtname style="HEIGHT: 22px; WIDTH: 185px" onchange="user10()"> // in user10() i submit the form explicitly. <option name="selectDistrict" selected> <div tal:repeat="district container/getDistrict"> <option tal:content="district/district_name"></option> </div> </select> 2nd drop down list : <select name=username style="HEIGHT: 22px; WIDTH: 185px" tal:condition="doDistrict" <div tal:repeat="user python:context.getDistrictUser(districtname=request.form['districtname'])"> <option tal:content="user/username"></option> </div> </select> That got rid of the error. I was wondering whether in my Python script getDistricUser i could also, by default, assume that i'm passing in districtname. Then I cud just say <div tal:repeat="user here/getDistrictUser"> which is more pleasing to the eye. By saying "or nothing" when I define variable doDistrict I can then test for it later. And it evaluates to false on the first pass. So any tips.
prabuddha ray wrote:
That got rid of the error. I was wondering whether in my Python script getDistricUser i could also, by default, assume that i'm passing in districtname. Then I cud just say <div tal:repeat="user here/getDistrictUser"> which is more pleasing to the eye.
By saying "or nothing" when I define variable doDistrict I can then test for it later. And it evaluates to false on the first pass.
So any tips.
Of course you can also access the form varialbes in your python script getDistrictUser with the same syntax: request.form['some_key'], if this script only expects its input from the form variable. Then you don't have to pass the parameter in your page template explicitly. -- HONG Yuan Homemaster Trading Co., Ltd. No. 601, Bldg. 41, 288 Shuangyang Rd. (N) Shanghai 200433, P.R.C. Tel: +86 21 55056553 Fax: +86 21 55067325 E-mail: hongyuan@homemaster.cn
participants (2)
-
Hong Yuan -
prabuddha ray