Re: [web2py] How to create a new record in database without submit buttons

2011-07-02 Thread portable dora
You were right Anthony.
And I found what I exactly needed was 'Components' .
I didn't want to refresh the entire page.
But anyways, the fact that there is the insert method and it doesn't give me
much to create a record from input forms, was new knowledge for me, so it
was good to know about it.
Thank you always helps me.

Dora

2011/7/2 Anthony 

> Note, in that case, you won't be taking advantage of any of the built-in
> form processing, such as input validation and return/display of form errors.
> To get the validation, you could use the .validate_and_insert() method, but
> you'd still have to manually process and deal with the potential validation
> errors returned.
>
> If you want a regular form submission and the usual form processing but
> simply want to submit without a submit button, maybe just use something like
> jQuery .submit(): http://api.jquery.com/submit/
>
> Anthony
>
> On Saturday, July 2, 2011 6:44:04 AM UTC-4, dorasan wrote:
>
>> 'Insert' method. That is what I wanted to know.
>> Thank you so much!!
>>
>> 2011/7/2 cjrh 
>>
>> In the method called by the AJAX event, you don't need the form at all.
>>> You can just do a straight insert. You must pass the data to be inserted as
>>> part of the AJAX call, either via args, or post data or some other method on
>>> the URL. Then, inside writing(), just do a direct DB insert as documented
>>> here: 
>>> http://web2py.com/book/**default/chapter/06#insert
>>
>>
>>


Re: [web2py] How to create a new record in database without submit buttons

2011-07-02 Thread Anthony
Note, in that case, you won't be taking advantage of any of the built-in 
form processing, such as input validation and return/display of form errors. 
To get the validation, you could use the .validate_and_insert() method, but 
you'd still have to manually process and deal with the potential validation 
errors returned.
 
If you want a regular form submission and the usual form processing but 
simply want to submit without a submit button, maybe just use something like 
jQuery .submit(): http://api.jquery.com/submit/
 
Anthony
 
On Saturday, July 2, 2011 6:44:04 AM UTC-4, dorasan wrote:

> 'Insert' method. That is what I wanted to know. 
> Thank you so much!!
>
> 2011/7/2 cjrh 
>
>> In the method called by the AJAX event, you don't need the form at all. 
>> You can just do a straight insert. You must pass the data to be inserted as 
>> part of the AJAX call, either via args, or post data or some other method on 
>> the URL. Then, inside writing(), just do a direct DB insert as documented 
>> here: http://web2py.com/book/default/chapter/06#insert
>
>
>

Re: [web2py] How to create a new record in database without submit buttons

2011-07-02 Thread portable dora
'Insert' method. That is what I wanted to know.
Thank you so much!!

2011/7/2 cjrh 

> In the method called by the AJAX event, you don't need the form at all.
>  You can just do a straight insert.  You must pass the data to be inserted
> as part of the AJAX call, either via args, or post data or some other method
> on the URL.  Then, inside writing(), just do a direct DB insert as
> documented here: http://web2py.com/book/default/chapter/06#insert


Re: [web2py] How to create a new record in database without submit buttons

2011-07-02 Thread cjrh
In the method called by the AJAX event, you don't need the form at all.  You 
can just do a straight insert.  You must pass the data to be inserted as 
part of the AJAX call, either via args, or post data or some other method on 
the URL.  Then, inside writing(), just do a direct DB insert as documented 
here: http://web2py.com/book/default/chapter/06#insert

[web2py] How to create a new record in database without submit buttons

2011-07-02 Thread dorasan
Hello everyone.

Could you tell me how to create a new record in database without
submit buttons?
I actually would like to do it by the onclick event.
I know that I can call the ajax function like this.

  

But I don"t know what I have to write in the 'def:writing'.
My code implemented by a submit button is this.


db.define_table('article',
   Field('title'),
   Field('text')
   )


def writing():
  form = SQLFORM(db.article)
  if form.accepts(request.vars, session, formname='article_works'):
  response.flash = 'Done'
  elif form.errors:
  response.flash = 'Error'
  else:
  response.flash = 'Write something'
  return dict(formkeyvalue=form.formkey, message=response.flash)


{{include 'web2py_ajax.html'}}

Title
Text




{{=message}}