SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2000
    Location
    Outside Providence
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript focus() not working - L@@K

    Hi! I was hoping someone could help me with this seemingly simple task. I have a page that loads with a bunch of input boxes (it's a timesheet). When the user clicks on an input field, I want the field to highlight (just like when a window puts a field in focus during the onload event).

    Why? Well, the users are entering time for a particular project. The time all defaults to zeros to start with (per the user's request). When they click in the field and add a value (7.5 for example), they end up with 07.5 in the field or are fussing with backspacing to remove the zero. I just thought if I could get the field to become "in focus" when someone clicks on it, thus having the entered value highlighted, then when they begin typing in the field, the entered value goes away and makes data entry less cumbersome. The problem is that it's just not working.

    Here's the code I'm using:

    <input type="text" name="d_Mon" size="5" value="<%=dept_Mon%>" onClick="javascript: document.TimeAssmnt.d_Mon.focus(); " onChange="Dept_Sum()">

    Anyone have an idea what I'm doing wrong?

    Thanks for your help!

    April
    TEAMWORK is the fuel that allows common people
    to produce uncommon results.

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2000
    Location
    Outside Providence
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, I should probably mention that the brackets are ASP code that puts a value in there and the onchange event is a javascript function that calculates the total. I don't think these are problems because the code works fine, but I thought I'd post the code exactly as is for your input.

    Thanks!
    TEAMWORK is the fuel that allows common people
    to produce uncommon results.


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
  •