Results 1 to 4 of 4

Thread: Cursor on search (Tornado)

  1. #1
    alarabie Guest

    Cursor on search (Tornado)

    I've noticed that none of the Tornado examples on sreeens that include input fields never have the cursor positioned to the first field or any other field, is there a way to do this? I would like to position the cursor to a specificic field in the search screen. I have a phone list with a search screen, and 95% of the time they will want to search by last name, this would eliminate the need to click into the field and then start typing, an anoyance to a lot of people.

    Thanks.

  2. #2
    John Guest

    Cursor on search (Tornado) (reply)


    Hi,

    You can accomplish this yourself with a little bit of JavaScript code. You simply need to use the &#34;setfocus()&#34; method. Put it in the <BODY> tag using an &#34;onLoad=&#34; parameter. Example:

    <BODY onLoad=&#34;mysetfocus()&#34;>

    Define that function up the the <HEAD> section and have it set focus to whatever field you wish.

    Example:

    <SCRIPT Language=&#34;JavaScript&#34;>
    function mysetfocus() {
    if (document.forms[0]) { //If there&#39;s a form up
    if (document.forms[0].elements[0].name == &#34;NAMEENTERED&#34 { //if out fld up
    document.forms[0].elements[0].focus(); //Set focus to it
    }
    }
    }
    </SCRIPT>
    Good luck,
    John

    ------------
    alarabie at 9/23/2002 7:01:18 PM

    I&#39;ve noticed that none of the Tornado examples on sreeens that include input fields never have the cursor positioned to the first field or any other field, is there a way to do this? I would like to position the cursor to a specificic field in the search screen. I have a phone list with a search screen, and 95% of the time they will want to search by last name, this would eliminate the need to click into the field and then start typing, an anoyance to a lot of people.

    Thanks.

  3. #3
    Guest

    Cursor on search (Tornado) (reply)

    I can,t seem to get it to work, here is my code.

    The page works fine but the cursor does not get set. I start my page on the search screen and the region field is the third field displayed (no 6 is the DB)

    <html>
    <head>
    <SCRIPT Language=&#34;JavaScript&#34;>
    function mysetfocus() {
    if (document.forms[0]) { //If there&#39;s a form up
    if (document.forms[0].elements[2] == &#34;region&#34 { //if out fld up
    document.forms[0].elements[2].focus(); //Set focus to it
    }
    }
    }
    </SCRIPT>


    <body OnLoad=&#34;mysetfocus();&#34;>


    <script language=&#34;vb&#34; runat=&#34;server&#34;>
    Sub Page_Load(Source as Object, E as EventArgs)
    Dim grid As New Tornado.Z()
    with grid
    .dbunit = 998
    .dbQP = &#34;m=g|d=phones|gdf=3,2,4,5,6,7,8&#34;
    .dbsql = &#34;Select * from [employee table] &#34;
    .dbskin = &#34;Air&#34;
    .dbfilterflds = &#34;3,2,6,7,8&#34;
    .dbpagesize = 10
    .dbsortflds = &#34;2,3,6,7,8&#34;
    .dbstartup = &#34;filter&#34;
    .dbNameMap = &#34;fi=2|alias=First Name,fi=3|alias=Last Name,fi=4|alias=Position,fi=5|alias=Number&#34;
    .dbNavigationItem = &#34;top,bottom,prev,next,filter,reload&#34;
    .dbtextholder=&#34;Title=District Attorney Phone List|subtitle=First enter search criteria, once results are displayed, you optionaly can; <BR>Click arrow to sort - Click opposite arrow to change order - Click same arrow to Unsort.<BR> Columns will line up to the left when sorted and return to original position when unsorted.&#34;
    .ASPdbNet
    end with

    End Sub



    </script>

    </body>

    </html>



    ------------
    John at 9/24/2002 2:32:48 AM


    Hi,

    You can accomplish this yourself with a little bit of JavaScript code. You simply need to use the &#34;setfocus()&#34; method. Put it in the <BODY> tag using an &#34;onLoad=&#34; parameter. Example:

    <BODY onLoad=&#34;mysetfocus()&#34;>

    Define that function up the the <HEAD> section and have it set focus to whatever field you wish.

    Example:

    <SCRIPT Language=&#34;JavaScript&#34;>
    function mysetfocus() {
    if (document.forms[0]) { //If there&#39;s a form up
    if (document.forms[0].elements[0].name == &#34;NAMEENTERED&#34 { //if out fld up
    document.forms[0].elements[0].focus(); //Set focus to it
    }
    }
    }
    </SCRIPT>
    Good luck,
    John

    ------------
    alarabie at 9/23/2002 7:01:18 PM

    I&#39;ve noticed that none of the Tornado examples on sreeens that include input fields never have the cursor positioned to the first field or any other field, is there a way to do this? I would like to position the cursor to a specificic field in the search screen. I have a phone list with a search screen, and 95% of the time they will want to search by last name, this would eliminate the need to click into the field and then start typing, an anoyance to a lot of people.

    Thanks.

  4. #4
    Join Date
    Oct 2002
    Posts
    93
    Your code is ALMOST right!

    In your second if check, you left out the ".name" parameter. Also, you're comparing it against "region". Where does that come from?

    Here's how to fix it:

    1) Comment out your second IF check (if xxx = "region") and the corresponding closing brace.

    2) Run it. It should now work.

    3) If you want to put that IF check back in, it should read:

    if (document.forms[0].elements[2].name == "ASPDB_FILTER_2_0") {

    That "2" in there is because you have elements[2]. If you had [3] you'd have _3_0.

    Good luck.

    John

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •