|
||||||
| JavaScript and CSS Extensible Markup Language, Java Script, and CSS questions here. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
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%> 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;
}
}
|
|
|||
|
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... |
|
|||
|
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
|
|
|||||
|
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! |
|
|||
|
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") & "'"
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. |
|
|||||
|
Quote:
__________________
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! |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
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 |
| orjan | ........ | 42 |
| WingedPanther | ........ | 28 |
| Turk4n | ........ | 16 |
| roboticforest | ........ | 11 |
| RobotGymnast | ........ | 6 |
| Logan | ........ | 5 |
| Andreilp | ........ | 2 |
| dman4real | ........ | 2 |
| techker | ........ | 2 |
| Max.89 | ........ | 2 |
Goal #1: 1,000 Blogs
Goal #2: 1,000 Wiki Pages
Complete: 18%, 20%