Maybe try triggering the onchange event when dropdown2_a is changed. You 
could do that by changing the dropdown1 Ajax call from:

ajax('{{=URL('default', 'getoptionsfordropdown2'})}}', [''], 'dropdown2')

to:

ajax('{{=URL('default', 'getoptionsfordropdown2'})}}', [''], ':eval')

Then in the getoptionsfordropdown2 function, instead of just returning the 
select HTML, you can return Javascript code that changes the select HTML 
and then triggers the onchange event. This is not tested, by something 
along these lines:

def getoptionsfordropdown2():
    html = [code to generate the select]
    return 'jQuery("#dropdown2").html("%s"); 
jQuery("#dropdown2_a").change();' % html

Anthony

On Sunday, April 26, 2015 at 9:24:13 AM UTC-4, Sarbjit wrote:
>
> Hi,
>
> I have used AJAX based cascading drop down menu based on slice "
> http://www.web2pyslices.com/slice/show/1526/cascading-drop-down-lists-with-ajax-2
> "
>
> I have introduced a third drop down whose value is populated based on the 
> selection of second drop down.
>
> I am using the following code : (Not the exact code, but it'll be enough 
> to explain the flow)
>
> *VIEWS:*
>
> <select>  <!-- DROPDOWN1-->
> onchange="jQuery('#dropdown2_a').empty();  
> ajax('{{=URL('default','getoptionsfordropdown2'})}}', [''], 'dropdown2');">
> ..
> </select>
> <span id='dropdown2'>
> <select id='dropdown2_a'>      <!-- DROPDOWN2-->
> onchange="jQuery('#dropdown3_a').empty();  
> ajax('{{=URL('default','getoptionsfordropdown3'})}}', [''], 'dropdown3');">
> </select>
> </span>
> <span id='dropdown3'>
> <select id='dropdown3_a'>   <!-- DROPDOWN3-->
> </select>
> </span>
>
> *CONTROLLER:*
>
> getoptionsfordropdown2/getoptionsfordropdown3:
>
> def ...
> .... query the db and build SELECT ....
> return SELECT(...)
>
>
> *Problem:*
>
> So, at any point of time, if the option in the drop down1 is not changed, 
> then everything works fine i.e. changes in dropdown2 updates the options in 
> dropdown3.
>
> However, once the dropdown1 option is changed, dropdown3 contents are not 
> RESET (No code for it, and I need some guidance for it). So, I have to 
> change the option in dropdown2 and come-back in order to change the options 
> in dropdown3. Basically, once an option is changed in drop down1, user has 
> to change the option in dropdown2 once in order to update the dropdown3.
>
> Can someone please suggest me on how to handle this situation such that 
> changing the dropdown1 should update dropdown3 as well (based on the value 
> of dropdown2).
>
> Is it possible to call multiple forcefully trigger the onchange event for 
> dropdown2 once it is re-populated based on the changes in dropdown1.
>
>
>

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

Reply via email to