Jump to content


Photo

Drop down help


  • Please log in to reply
5 replies to this topic

#1 mayu_bt

mayu_bt
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 12 March 2006 - 08:42 PM

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.


#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 12 March 2006 - 10:12 PM

<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>


#3 keeB

keeB
  • Staff Alumni
  • Advanced Member
  • 1,078 posts
  • LocationCalifornia

Posted 12 March 2006 - 10:20 PM

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.. [=

Come visit my site to see my latest projects
http://nick.stinemates.org/wordpress/


#4 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 12 March 2006 - 10:29 PM

[!--quoteo(post=354321:date=Mar 12 2006, 05:20 PM:name=keeB)--][div class=\'quotetop\']QUOTE(keeB @ Mar 12 2006, 05:20 PM) View Post[/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.

#5 keeB

keeB
  • Staff Alumni
  • Advanced Member
  • 1,078 posts
  • LocationCalifornia

Posted 12 March 2006 - 10:50 PM

[!--quoteo(post=354327:date=Mar 12 2006, 10:29 PM:name=hitman6003)--][div class=\'quotetop\']QUOTE(hitman6003 @ Mar 12 2006, 10:29 PM) View Post[/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! [=

Come visit my site to see my latest projects
http://nick.stinemates.org/wordpress/


#6 mayu_bt

mayu_bt
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 13 March 2006 - 10:04 PM

Thanks a ton HITMAN!! I guess the scripts are just a piece of cake to you!! :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users