mayu_bt Posted March 12, 2006 Share Posted March 12, 2006 Hi team,I am stuck in a huge problem..and need HELP!! please help me..I have generated an application to track the daily transaction of workers in my Office. But now I am very badly in need to track their break timings as well and hence want to include a dropdown some where in the page above the table view.This drop down should have list of break types like "coffee", "Lunch" etc.. and next to this drop down should be two buttons one called ‘start’and one called ‘end’.. when the user clicks ‘start’ the start datetime at this should be captured in a variable and when user clicks ‘end’ button the dtatetime at this point should be captured and the difference that is the break time should be recorded in separate table along with start and end time.And also initially the ‘end’ button should be disabled and when the user selects the breaktype from dropdown and clicks start button.. the ‘end’ button should be enabled and ‘start’ button should be disabled..PLEASE HELP....toplay: Edited title to be more meaningful. Quote Link to comment https://forums.phpfreaks.com/topic/4781-drop-down-help/ Share on other sites More sharing options...
hitman6003 Posted March 12, 2006 Share Posted March 12, 2006 [code]<script type="text/javascript"> var start; var type; function startbreak() { if (document.getElementById('btype').selectedIndex > 0) { var x = document.getElementById('btype'); type = x.options[x.selectedIndex].value; var d = new Date(); start = d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds(); document.getElementById('end').disabled = false; } else { alert("You must select a break type"); } } function endbreak() { var d = new Date(); //uncomment this line to redirect the page to store the values. You can //also use php on that page to determine the amount of time they spent on break //window.location.href = "pagetostoretimes.php?breaktype=" + type + "&starttime=" + start + "&endtime=" + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds(); alert("Start Time: " + start + "\nEnd Time: " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + "\nType: " + type); } </script><form method="post"> <select name="break" id="btype"> <option></option> <option value="smoke">Smoking</option> <option value="bathroom">Bathroom</option> <option value="screwing-off">Coffee</option> </select> <br /> <input type="button" value="Start Break" onclick="javascript: startbreak()" /> <input type="button" value="End break" id="end" onclick="javascript: endbreak();" disabled /></form>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/4781-drop-down-help/#findComment-16802 Share on other sites More sharing options...
keeB Posted March 12, 2006 Share Posted March 12, 2006 I like how it says 'No. I won't write it for you' in your signature, and yet you just wrote the guys code for him!!! [=I wouldn't use javascript... just because not everyone has it enabled.. Instead I would use the date function with a hidden input field and pass it along that way.. [= Quote Link to comment https://forums.phpfreaks.com/topic/4781-drop-down-help/#findComment-16806 Share on other sites More sharing options...
hitman6003 Posted March 12, 2006 Share Posted March 12, 2006 [!--quoteo(post=354321:date=Mar 12 2006, 05:20 PM:name=keeB)--][div class=\'quotetop\']QUOTE(keeB @ Mar 12 2006, 05:20 PM) [snapback]354321[/snapback][/div][div class=\'quotemain\'][!--quotec--]I like how it says 'No. I won't write it for you' in your signature, and yet you just wrote the guys code for him!!! [/quote]Yeah, it depends on what it is and my mood.If it's something that I've explained a thousand times then I'm less prone to posting it again. Part of it also has to do with whether I find it entertaining or not...if it's something that I haven't tried doing before, but might at some point in the future consider doing, then I'll write it to see if I can, and at that point I may as well post the code.And I didn't write the php...just the js.If it's for an intranet, then he should be able to control js being enabled or not...especially if it's something for "the man" to keep track of his people...they'll make it happen if they want it bad enough. Quote Link to comment https://forums.phpfreaks.com/topic/4781-drop-down-help/#findComment-16812 Share on other sites More sharing options...
keeB Posted March 12, 2006 Share Posted March 12, 2006 [!--quoteo(post=354327:date=Mar 12 2006, 10:29 PM:name=hitman6003)--][div class=\'quotetop\']QUOTE(hitman6003 @ Mar 12 2006, 10:29 PM) [snapback]354327[/snapback][/div][div class=\'quotemain\'][!--quotec--]Yeah, it depends on what it is and my mood.If it's something that I've explained a thousand times then I'm less prone to posting it again. Part of it also has to do with whether I find it entertaining or not...if it's something that I haven't tried doing before, but might at some point in the future consider doing, then I'll write it to see if I can, and at that point I may as well post the code.And I didn't write the php...just the js.If it's for an intranet, then he should be able to control js being enabled or not...especially if it's something for "the man" to keep track of his people...they'll make it happen if they want it bad enough.[/quote]:) Good explanation and outlook.. You seem like a good guy, hitman! [= Quote Link to comment https://forums.phpfreaks.com/topic/4781-drop-down-help/#findComment-16824 Share on other sites More sharing options...
mayu_bt Posted March 13, 2006 Author Share Posted March 13, 2006 Thanks a ton HITMAN!! I guess the scripts are just a piece of cake to you!! :) Quote Link to comment https://forums.phpfreaks.com/topic/4781-drop-down-help/#findComment-17155 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.