You could also alter the ajax function in web2py_ajax.html:
function ajax(u,s,t) {
var query="";
for(i=0; i<s.length; i++) {
if(i>0) query=query+"&";
var elem = jQuery("#" + s[i]);
if (elem.attr("type")=="checkbox" && elem.attr('checked') ==
false) continue;
query=query+encodeURIComponent(s[i])+"="+encodeURIComponent
(elem.val());
}
jQuery.ajax({type: "POST", url: u, data: query, success: function
(msg) { if(t==':eval') eval(msg); else document.getElementById
(t).innerHTML=msg; } });
}
That should mimic a normal submit with a checkbox.
On Aug 27, 7:20 pm, Jose <[email protected]> wrote:
> On 27 ago, 23:27, "mr.freeze" <[email protected]> wrote:
>
>
>
> > I'm not sure why it's always on but you can store the state of the
> > checkbox in a hidden field and pass it back with the ajax request like
> > so:
>
> > def search2():
> > form = FORM(
> > TABLE(
> > TR(INPUT(_name='mytxt', _id='mytxt', _value='a
> > text...')),
> > TR(INPUT(_type='checkbox', _name='mychk',
> > _id='mychk',_checked="true",_onclick="jQuery('#chkval').val
> > (this.checked)")),
> > TR(INPUT
> > (_type='hidden',_name='chkval',_id='chkval')),
> > TR(INPUT(_type="button", _value="Buscar",
> > _onclick="ajax('%s',['mytxt',
> > 'mychk','chkval'],'target');" % URL(r=request,f='bg_find2')))
> > )
> > )
>
> > return dict(form=form, target=DIV(_id='target'))
>
> > def bg_find2():
> > return request.var.chkval
>
> mr.freeze
>
> It is a good alternative, but hoped there would be something simple
> and straightforward.
>
> Thank you very much
>
> Jose
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---