Web Analytics Made Easy -
StatCounter Onfocus not working - CodingForum

Announcement

Collapse
No announcement yet.

Onfocus not working

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

  • Onfocus not working

    Oh so many questions....

    I have a text box, which is validated through a function. Once the function is finished, I want to return the focus to the field, but it doesn't seem to be working. Below is a snippet of the code:

    onkeyup="if (!(validatevalue({$question_code}, '{@ty}', '{$current_status}', this.value)))this.value='{$current_status}; this.onfocus()'"

    Any suggestions?

    thanks in advance

  • #2
    oops, apologies, it should say:

    onkeyup="if (!(validatevalue({$question_code}, '{@ty}', '{$current_status}', this.value)))this.value='{$current_status}; this.focus()'"


    there's no event such as "this.onfocus()"

    Comment


    • #3
      The single quote should come after {current status}

      onkeyup="if (!(validatevalue({$question_code}, '{@ty}', '{$current_status}', this.value)))this.value='{$current_status}'; this.focus()"

      All the code given in this post has been tested and is intended to address the question asked.
      Unless stated otherwise it is not just a demonstration.

      Comment


      • #4
        Sorry Phillip,

        I've worded the question wrongly!

        What I meant to say is that the field has focus, but the text is not highlighted again. Doesn't the focus() method do this, or is there another means to re-highlighting the text?

        Comment


        • #5
          Try: this.select()

          .....Willy

          Comment


          • #6
            aha!

            I knew there would be a way, thanks Willie

            Comment


            • #7
              sorry to be a pain, but I have another question.

              My problem is that the focus is continually highlighting the text each time.

              If I enter a single value, this is fine, but if I'm entering a value of 20, I enter the 2, then the 0 overwrites it! I need to execute both statements in the if condition, but the curly braces won't work for me, since it tries to interpret the value as an XML value.

              ie
              onkeyup="if (true) this.value='{$current_status}; this.select()'"

              therefore if true, then value= current status and highlight text.

              Comment

              Working...
              X