Coldfusion Populate form with dropdown selection using ajax

后端 未结 3 1144
感动是毒
感动是毒 2021-01-25 19:52

So I have a project that\'s using ColdFusion and it has a form with a dropdown.

See example: http://jsfiddle.net/mwoods98/KXmNK/

What I need to

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-25 20:06

    In my example, I have a set of drop downs that are tiered dependent (Coldbox 3.5+, CF9)

    Using bindCFC and cfajax , here is an example of the first two drop downs the second being dependent

    My view snippet

    
        
    
        
    
    

    My model (dynform) snippet

     
        
        
           SELECT
                   egc.nd_event_group_id                  group_id,
                   egc.short_desc                         group_name
           FROM    event_group_code egc
           WHERE   egc.status_code = 'A'
           ORDER BY egc.sort_order
        
        
    
    
    
            
        
        
            SELECT ec.event_id,           
                   ec.FULL_DESC as event_name              
            FROM   events ec
            WHERE  ec.event_group_id =   
    
        
        
    
    

    Though the above will work, I ended up ditching it for the jQuery/ajax return JSON approach. The reasons why:

    1. Coldbox way = Handlers should be doing the work, not views

    2. CFajax/cfselect was slower than jQuery ajax, and with less options. (What if I want a multiple select box? Or three data attributes returned rather than two?)

    3. I didn't want to use the cfform tag in my view, which cfselect requires

    I can post the jQuery ajax way if needed, but I think I answered the original question

提交回复
热议问题