SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jun 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    setting focus on textbox

    Hi.
    how do I set focus if Im expecting that priority is always 1 char of length while country is always 3 char of length.
    If I entered country next textbox should be company_name AND if I entered Priority next textbox should be Exchange.
    Currently if I enter EITHER COUNTRY OR PRIORITY next textbox always focus on company_name. WHATS WRONG WITH MY CODE.


    my script is as shown below:

    <script language="javascript">
    IF (DOCUMENT.FORM1.PRIORITY.VALUE.length=1)
    {function doOnLoad() {
    document.Form1.EXCHANGE.focus();}
    }

    ELSE
    IF (DOCUMENT.FORM1.COUNTRY.VALUE.length=3)
    {function doOnLoad() {
    document.Form1.COMPANY_NAME.focus(); }
    }
    </script>


    please help !!!!

    thanks in advance
    kazam35

  2. #2
    SitePoint Zealot
    Join Date
    Dec 2004
    Location
    Canada
    Posts
    162
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not really clear what you're after, but I can immediately see that
    IF (DOCUMENT.FORM1.PRIORITY.VALUE.length=1)
    should be
    IF (DOCUMENT.FORM1.PRIORITY.VALUE.length==1)
    You use double equals when making a comparison, single equals is an assignment.

  3. #3
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Other error is that JavaScript is case sensitive, so document and DOCUMENT is not the same thing

  4. #4
    SitePoint Member
    Join Date
    Jun 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi, I tried your suggestion but I still dont get the right result. what im trying to do in my form is there are several textbox and some like Country and Priority has autopostback to check if data users are entering exists. If the country textbox is entered next textbox focus should be at the company_name textbox and if Priority textbox is entered next textbox focus should be at the exchange textbox.


    additonal part of my code is:


    <Script Runat="Server">
    Private Sub CHECK_TIER (ByVal sender As Object, ByVal e As System.EventArgs)

    Dim fdbconn As SqlConnection
    Dim cmdSelect As SqlCommand
    Dim parmReturnValue As SqlParameter
    DIM STRUSER AS STRING
    Dim intResult As Integer
    DIM TIER AS NEW SQLParameter("@TIER", sqldbtype.VARCHAR,100)

    FDBconn = New SqlConnection( "Server=tfsphcogweb01;UID=sa;Database=dbdmfdb" )
    cmdSelect = New SqlCommand( "CHECK_TIER", FDBCONN )
    cmdSelect.CommandType = CommandType.StoredProcedure
    parmReturnValue = cmdSelect.Parameters.Add( "RETURN_VALUE", SqlDbType.Int) parmReturnValue.Direction = ParameterDirection.ReturnValue
    cmdSelect.Parameters.Add( "@PRIORITY", PRIORITY.TEXT)CMDSELECT.PARAMETERS.ADD(TIER)
    TIER.DIRECTION = PARAMETERDIRECTION.OUTPUT

    FDBconn.Open()
    cmdSelect.ExecuteNonQuery()
    STRUSER = cmdselect.parameters("return_value").value
    TIER.DIRECTION = PARAMETERDIRECTION.OUTPUT
    intResult = cmdSelect.Parameters( "RETURN_VALUE" ).Value
    FDBconn.Close()
    If intResult = - 1 Then
    lblMessage.Text = " PRIORITY Does not Exists "
    PRIORITY.TEXT = ""
    LBLTIER.TEXT = ""
    Else
    PRIORITY.TEXT = TIER.VALUE
    LBLTIER.TEXT = tier.value
    End If
    End Sub

    <body onload="return doOnLoad()">
    ...

    <asp:TextBox AutoPostBack="true" ID="PRIORITY" runat="server" TabIndex="7" OnTextChanged="check_tier" />

    </body>


Bookmarks

Posting Permissions

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