5 Replies Latest reply on Jan 8, 2014 9:52 AM by gkaiseril

    Simple JavaScript I just can't get to work

    CQuinn

      Hi guys I'm new here and to JavaScript really but I have had a go at trying this and it simply wont work for me. Basically I am creating a time-card for my work and because most people dont use military time the total calculations for each day have to take this into account. So I tried to make a script that would +12 if the total number of hours was less than 0; however it doesn't seem to work and still shows the negative number even though I have scripted it not too. I have attached the script bellow and if anyone could assist me it would be greatly appreciated.

       

      // Start Time

      var v1 = getField("Text1").value;

       

      // Finish Time

      var v2 = getField("Text2").value;

       

      // Lunch

      var v3 = getField("Text3").value;

       

      // Total Hours

      event.value = v2 - v1 - v3;

       

       

      if(parseInt(event.value < 0 )) event.value = (parseInt(event.value) + 12).toString();

       

       

      many thanks