Jump to:

23555 Posts in 19382 Topics by 2892 members

General Questions

SilverStripe Forums » General Questions » add onclick on search button

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 5517 Views
  • bebabeba
    Community Member
    192 Posts

    add onclick on search button Link to this post


    I create a form and I need ad a function with onclick. I prepare javascript file, I include this in my Page.php and i create the form like this:

    How can I add onclick="scrivi_campo();" in my button?

    function Ricerca() {

           $fields1 = new FieldSet(
              new TextField(
                  $name = "text",
                     $title = "Testo:",
                     $value = ""),
                     new HiddenField("error", "error", "1")

        $validator = new RequiredFields('text');      

       $actions = new FieldSet(
    new FormAction('doRicerca', 'CERCA')

    return new Form($this, 'Ricerca', $fields1, $actions, $validator);      

  • 3dgoo
    Community Member
    133 Posts

    Re: add onclick on search button Link to this post

    If you are using jquery, you can add the action to the button using javascript.

    So in formsearch.js you could put the following:

    ;(function($) {

       $('#whatever_button_id').click( function() {


Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.