You can call a controller function from view by using ajax.
The form is generated in controller as below.
TD(INPUT(_id='txt'+str(i+1)+'2',_name='txt'+str(i+1)+'2',value=row.lp_mcod,_style='width:100px;',_onblur='getDescr(this)'))

In the onblur event you call the javascript funciton defined below which in 
turn calls the controller function get_descr and fills element with the 
fetched results. 

function getDescr(e){
    var currentId = e.getAttribute('id');  //target.id;
    //alert(currentId);
    var nextId = currentId.substring(0,4);
    var n = parseInt(currentId.substring(4,5));
    var rowno = parseInt(currentId.substring(3,4));
    //alert(rowno);
    n = n + 1;
    nextId = nextId + String(n);
    nextIdN = '#' + nextId;
    //alert(nextId);
    currentIdN = '#' + currentId;
    //var table = document.getElementById('tblItems');
    //var row = table.rows[rowno];
    //var tb = row.cells[2].childNodes[0];
    //alert(tb.id);
    //ajax('get_descr',[currentId],'txtItemh');
    //fill_descr(rowno);
    
   var request = $.ajax({
      url: "/web_lp/lp/get_descr",
      method: "GET",
      data: { mcod : e.value},
      dataType: "text"
    });
 
    request.done(function( msg ) {
      $( nextIdN ).val( msg );
    });
 
    request.fail(function( jqXHR, textStatus ) {
      alert( "Request failed: " + textStatus );
    });
}

Hope this helps you.



-- 
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