fixing an inefficient timecard interface

Post Reply
JohnSmith1000
Posts: 2
Joined: 22.02.18 20:32:17

fixing an inefficient timecard interface

Post by JohnSmith1000 » 22.02.18 20:43:28

Issue:
We have a timecard program at work that we're forced to use and we have to enter the times in for Lunch Out, Lunch In, and
Clocking Out by choosing from a drop down list. Let's just say it is one of the most inefficient interfaces I've ever used, and I
would like to improve it.
What I've done:
I used a tutorial from a Greasemonkey website to create a button that when I press it, it loads in default values and this
works. The aim being that I just log in to each day and click my button "Load Template" and then click the "Clock Out" button.
Problem: Each time I click the "Clock Out" button, it erases all the values my code put in and basically just refreshes the page to a
default state.

I have experience with C++ but it's been a long time however I'm new to javascript,. What am I missing? Thank you for any help or pointers to tutorials that will help me fix this.

The code block for Lunch Out has an attribute of "value= 11:00 AM" and I've thought of adding that to the other code blocks
using

Code: Select all

$('cmbLunchOut_I').attr('value',"12:00 PM"); 
but it didn't work.

Here's the code I used that will put the values in the fields I want:

Code: Select all

(function() {
   'use strict';
var input=document.createElement("input");
input.type="button";
input.value="Load Template";
input.onclick = FillFields;
document.body.appendChild(input);

function FillFields()
{
    var mVarLunchOut = document.getElementById('cmbLunchOut_I');
    mVarLunchOut.value = "12:00 PM";
    //$('cmbLunchOut_I').attr('value',"12:00 PM"); (Didnt work)

    var mVarLunchIn = document.getElementById('cmbLunchIn_I');
    mVarLunchIn.value = "01:00 PM";
   
    var mVarClockOut = document.getElementById('cmbClockOut_I');
    mVarClockOut.value = "05:00 PM";   

}
})();

JohnSmith1000
Posts: 2
Joined: 22.02.18 20:32:17

Re: fixing an inefficient timecard interface

Post by JohnSmith1000 » 23.02.18 21:18:59

So I found a workaround for right now, it does save me quite a few keystrokes, but it isn't perfect. I changed my function to this:

Code: Select all

function FillFields()
{
    var mVarLunchOut = document.getElementById('cmbLunchOut_I').value = "12:00 PM";
    
    var mVarLunchIn = document.getElementById('cmbLunchIn_I').value = "01:00 PM";
    
    var mVarClockOut = document.getElementById('cmbClockOut_I').value = "05:00 PM";

}
The issue is I have to hit the down arrow on the combo boxes for each field as if I'm actually selecting the value, even though I'm not selecting anything. Like I said, it's a workaround that saves me quite a few keystrokes, so after some more reading I may be able to make it better.

Post Reply