Forum OpenACS Q&A: How do I add an "onclick" javascript event on a submit widget of an ad_form

Hallo,
I have a form generated by ad_form.
The form has a submit button (until now autogenerated by the ad_form).
I want to add the text onClick="Disab" in my button, (apparently to run a javascript to disable the button after the first click - to avoid an error which happens because of double clicks).

How do I add the text to the button in an ad_form?

Thanks,
Konstantinos

ad_form has a '-has_submit' flag that allows you to suppress the ad_form generated submit button and then you can supply your own. The confusing thing (to me) is that '-has_submit 1' means the submit button is not generated for you. In any case, here's a snippet that would do what you want:
ad_form -name test -form {
    field1:text
    {my_submit_button:text(submit) {label "Click me"} {html {onClick "Disab"}}}
} -has_submit 1
...
Thanks. That was it. It now works as I want it.