Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript time update with a dropdown

Status
Not open for further replies.

BulentYazici

Programmer
Oct 23, 2006
2
GB
Hello there,

I'm an experienced ASP developer with little experience in JS and was wondering if any of you would be able to help with the following problem I'm facing:

I'm doing a timesheet module where users select the tasks they've done during their shift, which is all stored into a DB. On the next page, I need to know exactly how much time they spent on each task.

So, if someone started working at 09:00 and finished at 12:00 and they've done 4 kinds of tasks, I want the following page to display something like:

------------------------------------------

3 hours = 180 minutes

[180 minutes] <-- This is a dynamic number, as minutes are assigned to tasks, this number decreases

Task 1 [0-180] <-- This is a drop down, consisting of 0-180 minutes in 15 minute blocks

Task 2 [0-180] <-- This is a drop down, consisting of 0-180 minutes in 15 minute blocks

Task 3 [0-180] <-- This is a drop down, consisting of 0-180 minutes in 15 minute blocks

Task 4 [0-180] <-- This is a drop down, consisting of 0-180 minutes in 15 minute blocks

--------------------------------

An example of this page can be found at:
Now, I can get it to create all the dynamic drop downs with the 15 minute blocks etc, using ASP. However, what I need to be able to do is the following:

- When a user selects the time they have spent on a specific task, it automatically reduces the remaining time left on top of the page, so that the user knows how much more time they need to assign
- When the total remainder time is down to, for example 30 minutes, the "Update Shift Details" button becomes activated.
- If possible, as the times for each task is changed, it reduces the time availabe for the other tasks (in the drop downs) (Not really that important, but on a wish list)

Any pointers or help would be much appreciated.

Many thanks

Bulent
 
You need to 1stly give this element an ID
Code:
<INPUT disabled size=4 value=400 name=minutesleft [b]id="minutesleft"[/b]>
then add to each select the ONCHANGE attribute calling a function..
onchange="recalc(this);"

Code:
function recalc(obj){

var mn = document.getElementById('minutesleft');

mn.value = mn.value - obj.value; 

}

should give you an idea!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Thanks 1DMF,

My question was actually answered on a different forum. Pretty much along the lines of what you've said but with a bit more detail.

Many thanks for your prompt reply.

This question has now been answered.
 
cool - glad you got it sorted :)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top