Hey,

I'm new to web2py.
I want to update a inputfield with the return value of a function.
when adding a new record to t_cre_customers, i want to lookup in table 
t_cre_contractors.
I'm using focusout event to launch.
Passing the argument of field t_cre_customers_f_ctm_no to function 
cre_find_contractor() 
does not work.
And return the result to the sqlform in field t_cre_customers_f_ctm_cr_atv_cd 
neither.
Thanks voor any help.

*db*

########################################
# TABLE : t_cre_contractors
########################################
db.define_table('t_cre_contractors',
    Field('f_ctt_no', type='string',
          label=T('Contractant number'),length=8),
    Field('f_ctt_cr_atv_cd', type='string',
          label=T('Credit activity code contractant'),length=8)
)

########################################
# TABLE : t_cre_customers
########################################
db.define_table('t_cre_customers',
    Field('f_ctm_no', type='string',
          label=T('Contractant number borrower'),length=8),
    Field('f_ctm_nm', type='string',
          label=T('Name borrower'),length=50),
    Field('f_ctm_cr_atv_cd', type='string',
          label=T('Credit activity code borrower'),length=8),
    auth.signature,
    format='%(f_ctm_nm)s'
)
db.t_cre_customers.f_ctm_no.requires=[IS_NOT_EMPTY()]
db.t_cre_customers.f_ctm_nm.requires=[IS_NOT_EMPTY()]


*controler*
# add customer
def cre_customer_add():
    form_add_customer = SQLFORM(db.t_cre_customers)
    if form_add_customer.process().accepted:
        response.flash = 'You have successfully submitted the form'
    elif form_add_customer.errors:
        response.flash = 'Please check your form for errors'
    else:
        response.flash = 'Please fill all fields!'
    return dict(form_add_customer=form_add_customer)

#find customer in table t_cre_contractors
def cre_find_contractor():
    waarde = request.args(0)
    response.flash = waarde
    return "test"

*view*
{{extend 'layout.html'}}
<h1>Add customer</h1>
<br/>
<br/>
{{=form_add_customer}}
<script>
    jQuery(document).ready(function(){
        jQuery('#t_cre_customers_f_ctm_cr_atv_cd__row').show();
});
    jQuery('#t_cre_customers_f_ctm_no').focusout(function(){
        jQuery('#t_cre_customers_f_ctm_cr_atv_cd__row').show();
        
ajax('{{=URL('default','cre_find_contractor')}}','t_cre_customers_f_ctm_no','t_cre_customers_f_ctm_cr_atv_cd');
});
</script>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/96c9fe15-b423-4b0a-a6f6-c28e59ce477f%40googlegroups.com.

Reply via email to