On Fri, Sep 21, 2012 at 7:20 AM, Yebach <[email protected]> wrote:

> Yes I know but have to insert it in a view, because using javascript there
> is where I select a value from drop down. The problem is that the value is
> not inserted and cannot be read in model


Ajax is the only way (or cookies)



This goes in the view

<script>
$(function(){
    $('#mySelect').change(function(){
        url = "{{=URL('default', 'add_to_session')}}"
        ajax(url, ['myselect'], my_callback);
    });
});

function my_callback(data){
    alert("Hello " + data);
}
</script>

<select id="mySelect" name="myselect">
    <option....>
</select>



This goes in controller

def add_to_session():
    value = request.vars.myselect
    session.value = value
   return "world!"


#note that mySelect is "id" and "myselect" is the name, the DOM uses
#mySelect while the ajax function sends 'myselect' to the server.

-- 



Reply via email to