Forum OpenACS Development: Javascript in ad_form

Collapse
Posted by Brad Poulton on
Is there a way to attach a Javascript call to a button in ad_form without creating a custom ad_form in the .adp? For example a Javascript confirm box popup?
Collapse
2: Re: Javascript in ad_form (response to 1)
Posted by Michael Aram on
Hello Brad,

first, you have to suppress the standard submit button by setting the switch has_submit to 1 (!).

then you can insert a button widget like this:

{mysubmit:text(submit)
{mylabel "mylabel"}
{html {onclick "alert('yeah');"}}
}

Collapse
3: Re: Javascript in ad_form (response to 1)
Posted by Michael Aram on
sorry, the label line is ignored:

this will suffice:
{mysubmit:text(submit)
{html {onclick "alert('yeah');"}}
}

Collapse
6: Re: Javascript in ad_form (response to 3)
Posted by Brian Fenton on
Thanks a million for this Michael! I was just trying to do the same thing when I found your post. I used the following to get a Ok/Cancel Javascript confirm:

{mysubmit:text(submit)
{label "Proceed"}
{html {onclick "return(confirm('Are you sure?'));"}}
}

cheers
Brian

Collapse
4: Re: Javascript in ad_form (response to 1)
Posted by Brad Poulton on
Thanks for the help!
Collapse
5: Re: Javascript in ad_form (response to 1)
Posted by Brad Poulton on
I have tried to create a page with the submit widgets, but i have found that the -edit_data is not firing. Can i use the custom widgets with an -edit_data?

{ Update:text(submit)

}
{ Delete:text(submit)

}
{ Cancel:text(submit)

}