SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,643
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    append values to a text box?

    I have a simple text box where I allow peolple to enter the time spent on a task. The problem is that some of my users put 4 (not saying 4 hours) and 50 (not saying 50 minutes). Is there a way to have 2 radio buttons right next to the text box indicating whether its in hours or minutes and those words would be added to whatever was entered in the text box?
    Thank you!
    "Oh, and Jenkins--apparently your mother died this morning."

  2. #2
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Midwest
    Posts
    777
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This may not be the exact syntax, but it should be close…

    Have a JavaScript function do something like.

    Code:
    var txtHoursRef = document.getElementById('txtHours');
    txtHoursRef.value = txtHoursRef.value + “ “ + “Minutes”; 
    
    - or -
    
    txtHoursRef.value = txtHoursRef.value + “ “ + “Hours”;
    If you want to use a radio button, just get the value from the radio button and insert that value in for Minutes and Hours.

    Hope this helps.

  3. #3
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,643
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Yes, thank you.
    Should I run the function on the radio buttons onclick event?
    "Oh, and Jenkins--apparently your mother died this morning."

  4. #4
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Midwest
    Posts
    777
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would probably default the radio button to the value that most people use. Then I would have a submit button they must press after they entered their time and the time type (hours, minutes). The submit button would be where I would have the JavaScript called.

    Just as a side note… I worked on a time tracking project a few years ago and we restricted time entry in half hour increments to prevent some of this confusion. Just a thought.


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
  •