Furthermore... strange. If I print the request.vars.dpt somewhere in the 
'add_experience' function, the value is printed every time I select an 
option n the first drop-down.

However, If I just want to return this:

ranks = db(db.rank.department_id == request.vars.dpt).select(orderby=db.rank
.name)

and then check if 'ranks' exists in my view - I get False...

Do I need an Ajax call to somehow achieve my goal?

On Monday, June 17, 2013 1:35:51 AM UTC+2, lesssugar wrote:
>
> Yes, I checked: the load function is being triggered and *dpt* variable 
> is being set in the function every time I select an option from the first 
> drop-down.
>
> The respective view fragment:
>
> <div class="w2p_fw">
>     <select class="generic-widget" id="seafarer_experience_rank" 
> name="rank">
>         {{=result}}
>     </select>
> </div>
>
> (The HTML is fixed just for now, I've cut the dynamic code to test the 
> auto-populating only...)
>
> Not sure if I get the part about rendering "a complete page layout", 
> though, but it's a secondary issue for at this point.
>
>
> On Monday, June 17, 2013 12:47:57 AM UTC+2, villas wrote:
>>
>> Hmm I'm not sure you have given enough info.  Anyhow:
>>
>> Check in Firebug whether the load function is being triggered.
>> Place print statements in your function to test that the variables are 
>> being set.
>> Bear in mind that "return dict(...)"  will render a complete page 
>> layout.  I wonder if that is what you want? 
>> Check out the SELECT and OPTION helpers.
>>
>>
>> On Sunday, 16 June 2013 23:10:12 UTC+1, lesssugar wrote:
>>>
>>> I need to auto-populate my 'ranks' drop-down based on the value selected 
>>> in the 'department' one.
>>>
>>> This is my script:
>>>
>>> <script>
>>> $("#department").change(function() {
>>> $("#ranks").load("?dpt=" + $("#department").val());
>>> });
>>> </script>
>>>
>>> As you can see, I pass *dpt *var to my current function. This is its 
>>> code:
>>>
>>> def add_experience():
>>>
>>>     ranks = db(db.rank.department_id == request.vars.dpt).select(orderby=
>>> db.rank.name)
>>>
>>>     result = ""
>>>
>>>     for r in ranks:
>>>         result += "<option value='" + str(r.id) + "'>" + r.name + 
>>> "</option>"
>>>
>>>
>>>     return dict(result=XML(result))
>>>
>>> When I select a value in the first drop-down, a request is being sent to 
>>> [controller]/add_experience?dpt=[value selected]. However the second 
>>> drop-down does not populate with respective data - it's empty. I'm clearly 
>>> missing something. Any help?
>>>
>>>

-- 

--- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to