Closed Thread
Results 1 to 10 of 10

Thread: javascript help!!

  1. #1
    aicirt Guest

    javascript help!!

    im kinda unsure where this post should go... but here goes...

    right now i have these 2 text fields...

    Code:
    <%if v_cnt mod 2 = 0 then%>
    <td align="center"><INPUT type="text" name=txtClockTime maxlength=5 size=5 value="<%=formatdatetime(v_HistTime,4)%>" style="font-family : Tahoma, Sans-Serif, Verdana, Geneva, Arial, Helvetica; background:#F2F5FE; font-size : 8pt; color: #31345C"></td>
    <td width="11"><img src="/images/control/eTimeClock/div.gif"></td>
    <%else%>
    <td align="center"><INPUT type="text" name=txtClockTime maxlength=5 size=5 value="<%=formatdatetime(v_HistTime,4)%>" style="font-family : Tahoma, Sans-Serif, Verdana, Geneva, Arial, Helvetica; background:#F2F5FE; font-size : 8pt; color: #31345C"></td>
    <td width="11"><img src="/images/control/eTimeClock/div.gif"></td>
    <%end if%>
    and i have this function to check for it...

    Code:
    function ValidateTime(){
    // Checks if time is in HH:MM format.
    //Clock-in time 
    var i = 0	
    timeStr = document.Report.txtClockTime(0).value;
    var timePat = /^(\d{1,2}):(\d{2})?$/;
    var matchArray = timeStr.match(timePat);
    if (matchArray == null) {
    alert("Clock-In time must be in a valid format(HH:MM).");
    return false;
    }
    hour = matchArray[1];
    minute = matchArray[2];
    
    if (hour < 0  || hour > 23) {
    alert("Clock-In hour must be between 0 and 23.");
    return false;
    }
    
    if (minute<0 || minute > 59) {
    alert ("Clock-In minute must be between 0 and 59.");
    return false;
    }
        
    //Clock-Out time 
    i = 1
    timeStr = document.Report.txtClockTime(1).value;
    	
    var timePat = /^(\d{1,2}):(\d{2})?$/;
    
    var matchArray = timeStr.match(timePat);
    if (matchArray == null) {
    alert("Clock-Out time must be in a valid format(HH:MM).");
    return false;
    }
    hour = matchArray[1];
    minute = matchArray[2];
    
    if (hour < 0  || hour > 23) {
    alert("Clock-Out hour must be between 0 and 23.");
    return false;
    }
    
    if (minute<0 || minute > 59) {
    alert ("Clock-Out minute must be between 0 and 59.");
    return false;
    }
    	
                    var sClockin  = document.Report.txtClockTime(0).value
                    var sClockout  = document.Report.txtClockTime(1).value
    		
    	sClockin = sClockin.replace(/:/gi,"");
    	sClockout = sClockout.replace(/:/gi,"");
    		
    	if (parseInt(sClockout) < parseInt(sClockin))
    	{
    		//alert(parseInt(sClockout));
    		//alert(parseInt(sClockin));
    		alert ("Clock-Out time must be greater than or equal to Clock-In time");
    		return false;
    	}
    }
    it's actually some kind of clocking system that allows people to clock in and out to keep track of their working hours and stuff... right now it only checks for 1st set of clock in and out... i wanna change it such that it checks for more than the 2 entries in cases where there are multiple entries and i dont know how... desperate for help =(

  2. CODECALL Circuit advertisement

     
  3. #2
    Lop's Avatar
    Lop
    Lop is offline Speaks fluent binary
    Join Date
    May 2006
    Posts
    1,178
    Rep Power
    30
    Hey aicirt, I'm not sure what you mean that you want it to check for two clock-in and clock-out. If the same users clocks-in twice, is that what you want to check?

  4. #3
    aicirt Guest
    yeah something like that. like when a user clock in for work. clock out for lunch. clock in after lunch. clock out after work.

    Clock in : 08:00
    Clock out : 12:00
    Clock in : 13:00
    Clock out : 18:00

    this would be a case of more than 2 entries...

  5. #4
    Lop's Avatar
    Lop
    Lop is offline Speaks fluent binary
    Join Date
    May 2006
    Posts
    1,178
    Rep Power
    30
    I've looked over the function you sent and all that function does it validate that a valid time is entered. You must have left something out above. Is there more functions and is there a server side language like PHP storing the values?

  6. #5
    aicirt Guest
    do u mean this ?

    Code:
    if Request.Form("sbUpdate") <>"" then
    		
    	v_SelectedId=Request.Form("HdnUserGUID")
    	v_SelectedDate=Request.Form("cmbYear") & Request.Form("cmbMonth") & Request.Form("cmbDay")
    	
    	v_SqlHistory="select time_in,time_out,user_operation,time_in_act,id from etimeclock_data where gu_id='" & v_SelectedId & "' and company_id='" & v_CompanyId & "' and (convert(varchar(8),time_in,112)='" & v_SelectedDate & "' or convert(varchar(8),time_out,112)='" & v_SelectedDate & "')"
    	rsHistory.Open v_SqlHistory,Application("econn"),3,1,1 
    		
    	v_Count=1
    	do while rsHistory.EOF =false 
    
    		if Request.Form("txtClockTime").Item(v_Count) <> "" then
    		
    			if rsHistory("user_operation") = "i" then
    				tmpDate	= formatdatetime(rsHistory("time_in"),2)
    				tmpField= tmpDate & " " & Request.Form("txtClockTime").Item(v_Count)
    				v_arrSqlQuery="update etimeclock_data set time_in='" & tmpField & "' where gu_id='" & v_SelectedId & "' and company_id='" & v_CompanyId & "' and convert(varchar(8),time_in,112)='" & v_SelectedDate & "' and id='" & rsHistory("id") & "'"
    			else
    				tmpDate	= formatdatetime(rsHistory("time_out"),2)
    				tmpField=tmpDate & " " & Request.Form("txtClockTime").Item(v_Count)
    				v_arrSqlQuery="update etimeclock_data set time_out='" & tmpField & "' where gu_id='" & v_SelectedId & "' and company_id='" & v_CompanyId & "' and convert(varchar(8),time_out,112)='" & v_SelectedDate & "' and id='" & rsHistory("id") & "'"
    			end if
    			
    			arrSql(v_Count)=v_arrSqlQuery
    		end if
    		v_Count=v_Count+1
    		rsHistory.MoveNext
    	loop
    
    end if

  7. #6
    Jordan Guest
    If you can either attach your entire program/website here or send it to me via email or PM I'll have a look at it and try to get it working the way you like.

  8. #7
    aicirt Guest
    id love to... but the code is duper long it scared the system out. i cant pm you and u didnt enable email. so... ya =\

  9. #8
    brackett is offline Programmer
    Join Date
    May 2006
    Posts
    192
    Rep Power
    22
    I don't see enough code to give you a definitive answer, but it looks like your problem is that you're doing an update statement:
    Code:
    v_arrSqlQuery = "update etimeclock_data set time_in='" & _
       tmpField & "' where gu_id='" & v_SelectedId & "' and company_id='" & _
       v_CompanyId & "' and convert(varchar(8),time_in,112)='" & _
       v_SelectedDate & "' and id='" & rsHistory("id") & "'"
    You'd want that to be an INSERT statement. I suspect this would involve some database changes as well, though. I'm a little unclear on the logic of the snippet, but it looks like you actually insert more than 1 time value? And, depending on what the last operation was, you do a clock in/clock out?

    Also, while it's not really relevant to your problem, I have to point out that your concatenated sql strings are ripe for a sql injection. If this is only used by trusted users, you'll probably be ok - but you may want to read up on sql injection for your next project.

  10. #9
    Jordan Guest
    Quote Originally Posted by aicirt
    id love to... but the code is duper long it scared the system out. i cant pm you and u didnt enable email. so... ya =\
    You should be able to PM me fine. Click on my name and then "Send Private Message"

  11. #10
    aicirt Guest
    yah the codes too long to fit in to PM that's wad i meant ...

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. javascript help
    By -Hurricane- in forum JavaScript and CSS
    Replies: 3
    Last Post: 05-06-2010, 06:53 AM
  2. javascript help
    By hkp in forum JavaScript and CSS
    Replies: 2
    Last Post: 06-04-2009, 11:55 PM
  3. JavaScript
    By Bannana97 in forum JavaScript and CSS
    Replies: 5
    Last Post: 02-19-2009, 03:54 AM
  4. C++ and JavaScript
    By aloplop in forum C and C++
    Replies: 0
    Last Post: 09-22-2008, 07:24 AM
  5. CRC (JavaScript)
    By RobotGymnast in forum JavaScript and CSS
    Replies: 3
    Last Post: 04-21-2008, 01:02 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts