Hello!

I've a form where i store country, state and municipality and i need to 
dynamcally change the value based on the select, i mean: If i select a X 
country i need to display only the states of the country "X" in the states 
dropdown, the same with municipality

I used a basic approach that i've used many times befores in other 
languages, a jquery function on dropdown change that ajax call a page and 
it returns the options and put it into the dropdown, i've been researching 
and found this really helpful: 
http://stackoverflow.com/questions/10387672/web2py-dropdown-menu, so based 
on this answer i build this structure:

On the controller: 

def ajaxMunicipio():
    if request.args(0) in db.estados.id:
        response.generic_patterns = ['load']
        data = db(db.municipios.estado == request.args(0)).select()
        html = "\<select\>"
        for fila in data:
            html += "\<option 
value=\""+str(fila.id)+"\"\>"+fila.nombre+"\</option\>"
        html += "\</select\>"
        return dict(form=html)
    else:
        raise HTTP(404)





And on the view:

  jQuery(function() {
    jQuery('#no_table_estado_id').change(function() {
      var request = $.ajax({
        url: "{{=URL('hot', 'ajaxMunicipio.load')}}" + "/" + 
jQuery(this).val(),
        method: "GET",
        dataType: "html"
    });    
      request.done(function(html) {
        console.log(html)
        $("#no_table_municipio_id").val(html);
      });
    })
  })



everything works well on the call side but i recieve the HTML sanitized 
like this: \&lt;select\&gt;\&lt;option 
value=&quot;1&quot;\&gt;LIBERTADOR\&lt;/option\&gt;\&lt;/select\&gt;

So i'm looking for a way to avoid web2py to sanitize the html, or maybe a 
cleanest way to do this because i dont really like looping the data in the 
controller in order to create the HTML

I appreciate any help you can give! Thanks for your atention


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

Reply via email to