Announcement

Collapse
No announcement yet.

Set focus on search field in a grid

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Set focus on search field in a grid

    Hy,

    In a grid application, I would like to have cursor focus set on the first field of the search form.
    I have tried to use sc_set_focus on refresh event with no luck.

    Any idea ?

    Thanks
    Massimiliano Campagnoli

  • #2
    Use inspector to know selector of search field, and try with.

    Code:
    echo '
    <script>
       $( "selector" ).focus();
    </script>
    ';
    /Giuseppe

    Professional Scriptcase Services
    Some Customers opinions

    Comment


    • #3
      Thanks a lot
      Massimiliano Campagnoli

      Comment


      • #4
        I've used plain javascript in the OnRefresh event :

        $focus="<script> document.getElementById('SC_riferimento').focus(); </script>";
        echo $focus;


        it does not work.

        Any idea ?
        Massimiliano Campagnoli

        Comment


        • #5
          Didn't tried, but for Quick search for example, try:

          $focus='<script> $("#SC_fast_search_top").focus(); </script>';
          echo $focus
          /Giuseppe

          Professional Scriptcase Services
          Some Customers opinions

          Comment


          • #6
            The trick is to postpone the focus once the page is fully loaded.

            here is a code that works:

            echo "<script>document.addEventListener('DOMContentLoad ed', function() {document.getElementById('SC_riferimento').focus() ;}, false);</script>";
            Massimiliano Campagnoli

            Comment


            • #7
              you can also try using the getelementsbyname method. I've found that in scriptcase generated code getelementbyid not always works.

              regards

              Comment

              Working...
              X