Assuming you build your buttons in the controller, you could make
this:
<input type="button" id="1" value="1" class="button">
<input type="button" id="2" value="2" class="button">
<input type="hidden" name="tmp" id="tmp">
<div id=target name=target></div>
Then in your javascript, after document.ready, something like this:
jQuery('.button').click(function(){
//any browser-side processing code would go here
val value=this.id;
jQuery('#tmp').val(value);
ajax('your_server_side_function', ['tmp'], 'target');
});
Caution: javascript code may contain typos.
On Sep 10, 6:45 pm, António Ramos <[email protected]> wrote:
> Hello,
>
> the ajax function example in the web2py book
>
> ajax('{{=URL('new_post')}}',['your_message'], 'target');
>
> sends the value of the field *your_message* to the controller function
>
> I dont want to send the value of a field but a button onclick action
>
> My webpage can have 2,4 10 or 20 buttons. It depends . And each time i press
> a button i need to call the ajax function to process that button
>
> can the ajax function process a button instead of a text field?
>
> Thank you