I am not very sure about the first approach; but with the second
approach, you are not passing the variable and regardless of that, you
don't have any argument for a controller function. It should be
something like-

image1 = FORM (TABLE (TR(TD(INPUT(_type = "submit", _value =
"delete",_id="delete_button" ,
           _onclick="javascript:
$.post(URL(r=request,c='default',f='delete_image',
args=[image.id])}})"))))

Controller function-

def delete_image():
    id = request.args[0]
    db(db.image.id==id).delete()
    return ''

On Nov 21, 12:40 pm, beroz <[email protected]> wrote:
> Dear Sir,
>
> I got stuck in something.. I want to call a controller function
> _onclick of a submit field. For example :
>
> I used two ways:
>
> 1.
> image1 = FORM (TABLE (TR(TD(INPUT(_type = "submit", _value =
> "delete",_id="delete_button" ,
>            _onclick= delete_image(id) ))))
>
> OR:
>
> image1 = FORM (TABLE (TR(TD(INPUT(_type = "submit", _value =
> "delete",_id="delete_button" ,
>            _onclick="javascript:
> $.post(URL(r=request,c='default',f='delete_image')}})"))))
>
> And in the same controller.. there will be a function :
>
> def delete_image (id):
>     print "image deleted-- : " + str (id)
>     db(db.image.id==id).delete()
>     print "deleted syccessfully"
>     return True
>
> It didn't work :(((((((((((((((((((((((((((((((((((((((
>
> My question is: is that possible? or how could I call a controller
> function onclick of submit button?
>
> Abeer

Reply via email to