Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > JavaScript and CSS

JavaScript and CSS Extensible Markup Language, Java Script, and CSS questions here.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-18-2006, 09:42 PM
Newbie
 
Join Date: Jul 2006
Posts: 5
Credits: 0
Rep Power: 0
aicirt is on a distinguished road
Default 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 =(
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-19-2006, 11:21 AM
Lop's Avatar   
Lop Lop is offline
Speaks fluent binary
 
Join Date: May 2006
Posts: 1,149
Credits: 0
Rep Power: 18
Lop will become famous soon enoughLop will become famous soon enough
Default

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?
__________________
Lop
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-19-2006, 09:15 PM
Newbie
 
Join Date: Jul 2006
Posts: 5
Credits: 0
Rep Power: 0
aicirt is on a distinguished road
Default

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...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-20-2006, 11:34 AM
Lop's Avatar   
Lop Lop is offline
Speaks fluent binary
 
Join Date: May 2006
Posts: 1,149
Credits: 0
Rep Power: 18
Lop will become famous soon enoughLop will become famous soon enough
Default

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?
__________________
Lop
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-20-2006, 09:51 PM
Newbie
 
Join Date: Jul 2006
Posts: 5
Credits: 0
Rep Power: 0
aicirt is on a distinguished road
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 07-22-2006, 04:17 PM
Jordan's Avatar   
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 10,944
Last Blog:
Artificial Intelligenc...
Credits: 1
Rep Power: 20
Jordan is just really niceJordan is just really niceJordan is just really niceJordan is just really nice
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

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.
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 07-27-2006, 11:49 PM
Newbie
 
Join Date: Jul 2006
Posts: 5
Credits: 0
Rep Power: 0
aicirt is on a distinguished road
Default

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 =\
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 07-28-2006, 09:43 PM
Programmer
 
Join Date: May 2006
Posts: 193
Credits: 0
Rep Power: 11
brackett is on a distinguished road
Default

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 08-01-2006, 02:16 PM
Jordan's Avatar   
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 10,944
Last Blog:
Artificial Intelligenc...
Credits: 1
Rep Power: 20
Jordan is just really niceJordan is just really niceJordan is just really niceJordan is just really nice
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

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"
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 08-01-2006, 09:16 PM
Newbie
 
Join Date: Jul 2006
Posts: 5
Credits: 0
Rep Power: 0
aicirt is on a distinguished road
Default

yah the codes too long to fit in to PM that's wad i meant ...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting Files with JavaScript Matt JavaScript and CSS 5 08-01-2007 01:02 PM
Quikly help javascript help JavaScript and CSS 2 02-20-2007 09:45 AM
Javascript accessing PHP Ronin JavaScript and CSS 0 11-08-2006 07:29 PM
Javascript Problem on Firefox streulich JavaScript and CSS 10 10-17-2006 07:40 PM
JSP = JavaScript? Ronin JavaScript and CSS 1 08-13-2006 07:56 AM


All times are GMT -5. The time now is 05:42 PM.

Contest Stats

orjan ........ 42
WingedPanther ........ 28
Turk4n ........ 16
roboticforest ........ 11
RobotGymnast ........ 6
Logan ........ 5
Andreilp ........ 2
dman4real ........ 2
techker ........ 2
Max.89 ........ 2

Contest Rules

CodeCall Goal

Goal #1: 1,000 Blogs
Goal #2: 1,000 Wiki Pages
Complete: 18%, 20%

Bounty

Prize: CodeCall Travel Mug
Requirement: Blogs/WiKi
Description: Click

Ads