Jump to content

Drop down help


mayu_bt

Recommended Posts

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.
Link to comment
Share on other sites

[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()" />&nbsp;&nbsp;<input type="button" value="End break" id="end" onclick="javascript: endbreak();" disabled />
</form>[/code]
Link to comment
Share on other sites

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.. [=
Link to comment
Share on other sites

[!--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.
Link to comment
Share on other sites

[!--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! [=
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.