landslide
02-15-2007, 04:55 PM
:confused: I have a page that pulls info from a database and displays it on the page. The problem is that the record keeps repeating the same info about 20 times then dispays the next record. Any Idea why? Here is my code. <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="../../../Connections/lvcc.asp" -->
<%
var Recordset1 = Server.CreateObject("ADODB.Recordset");
Recordset1.ActiveConnection = MM_lvcc_STRING;
Recordset1.Source = "SELECT tblJanuary.SSN, tblJanuary.EOD, [tblJanuary.Last four], tblJanuary.firstname, tblJanuary.lastname, tblJanuary.ORGCODE, tblTollFreeEmployees.SCD, tblJanuary.SEID, tblJanuary.jan9, tblJanuary.extra2, tblJanuary.timestamp1 FROM tblJanuary, tblTollFreeEmployees WHERE [tblTollFreeEmployees.SEID] = [tblJanuary.SEID] and tblJanuary.jan9 LIKE ('R%') OR tblJanuary.jan9 LIKE ('R%') OR tblJanuary.jan9 LIKE ('2%') OR tblJanuary.jan9 LIKE ('2,%') OR tblJanuary.jan9 LIKE ('2, C%') OR tblJanuary.jan9 LIKE ('2, D%') ORDER BY tblJanuary.EOD, SCD, [Last Four]";
Recordset1.CursorType = 0;
Recordset1.CursorLocation = 2;
Recordset1.LockType = 1;
Recordset1.Open();
var Recordset1_numRows = 0;
arjan9 = new Array();
arSeid = new Array();
var f=new Enumerator(Request.Form);
var el;
var start;
var len;
var idx;
for (; !f.atEnd(); f.moveNext()) {
el = f.item().toString().toLowerCase();
start = el.indexOf("_");
if(start > -1) {
start++; len = el.length - start;
idx = parseInt(el.substr(start, len));
if(!isNaN(idx)) {
if(el.indexOf("jan9")!=-1) arjan9[idx] = Request.Form(el);
if(el.indexOf("seid")!=-1) arSeid[idx] = Request.Form(el);
}
}
}
for(var i=0;i<arSeid.length;i++) {
if(arjan9[i] && arSeid[i]) {
updateDB (arjan9[i], arSeid[i]);
}
else {
Response.Write("");
}
}
function updateDB(param_jan9, param_seid) {
var update = Server.CreateObject("ADODB.Command");
update.ActiveConnection = MM_lvcc_STRING;
update.CommandText = update.CommandText = "UPDATE tblJanuary SET jan9 = '" + param_jan9 + "' WHERE seid = '" + param_seid + "'";
update.CommandType = 1;
update.CommandTimeout = 0;
update.Prepared = true;
update.Execute();
}
var Repeat1__numRows = -1;
var Repeat1__index = 0;
Recordset1_numRows += Repeat1__numRows;
%>
<%
var Recordset2__MMColParam = "1";
if (String(Session("MM_Username")) != "undefined" &&
String(Session("MM_Username")) != "") {
Recordset2__MMColParam = String(Session("MM_Username"));
}
%>
<%
var Recordset2 = Server.CreateObject("ADODB.Recordset");
Recordset2.ActiveConnection = MM_lvcc_STRING;
Recordset2.Source = "SELECT LASTNAME, FIRSTNAME, SEID FROM Adminlogin WHERE SEID = '"+ Recordset2__MMColParam.replace(/'/g, "''") + "'";
Recordset2.CursorType = 0;
Recordset2.CursorLocation = 2;
Recordset2.LockType = 1;
Recordset2.Open();
var Recordset2_numRows = 0;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
<!--
function doCalcs(form1){
count = form1.lvavalbl.value;
for(x=0; x<document.getElementsByName('jan9').length; x++){
document.getElementsByName('jan9')[x].value = (count > 0) ? 'A' : 'D'
count --;
}
}
//-->
</script>
<style type="text/css">
<!--
body {
background-color: #0099FF;
}
.style8 {
font-size: 24px;
font-weight: bold;
}
-->
</style></head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>jan9</title>
<style type="text/css">
<!--
.style7 {font-size: 9px}
-->
</style>
</head>
<body>
<p align="right"><a href="Jan10approve.asp">Click here to continue to the next day. </a></p>
<p align="center"><span class="style9 style7">Approved by <%=(Recordset2.Fields.Item("FIRSTNAME").Value)%> <%=(Recordset2.Fields.Item("LASTNAME").Value)%></span></p>
<form method="post" id="form1" name="form1" action="">
<p align="center" class="style8">January 9th </P>
<p align="center">Input the amount of leave that can be given
<input name="lvavalbl" type="text" id="lvavalbl" size="2" onblur="doCalcs(form1)"/>
</P>
<table border="1" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td><span class="style7">ID</span></td>
<td><span class="style7">EOD</span></td>
<td><span class="style7">SCD</span></td>
<td><span class="style7">Last four</span></td>
<td><span class="style7">Firstname</span></td>
<td><span class="style7">Lastname</span></td>
<td><span class="style7">ORGCODE</span></td>
<td><span class="style7">SEID</span></td>
<td><span class="style7">Jan9</span></td>
<td><span class="style7">timestamp1</span></td>
</tr>
<% while ((Repeat1__numRows-- != 0) && (!Recordset1.EOF)) { %>
<tr>
<td><span class="style7"><%=(Recordset1.Fields.Item("SSN").Value)%></span></td>
<td><span class="style7"><%=(Recordset1.Fields.Item("EOD").Value)%></span></td>
<td><span class="style7"><%=(Recordset1.Fields.Item("SCD").Value)%></span></td>
<td><span class="style7"><%=(Recordset1.Fields.Item("Last four").Value)%></span></td>
<td><span class="style7"><%=(Recordset1.Fields.Item("firstname").Value)%></span></td>
<td><span class="style7"><%=(Recordset1.Fields.Item("lastname").Value)%></span></td>
<td><span class="style7"><%=(Recordset1.Fields.Item("ORGCODE").Value)%></span></td>
<td><input name="seid_<%=Repeat1__index%>" type="text" id="seid_<%=Repeat1__index%>" value="<%=(Recordset1.Fields.Item("SEID").Value)%>" size="5" maxlength="5" readonly="<%=(Recordset1.Fields.Item("SEID").Value)%>" /></td>
<td><input name="jan9_<%=Repeat1__index%>" type="text" id="jan9" value="<%=(Recordset1.Fields.Item("jan9").Value)%>" size="4" /></td>
<td><span class="style7"><%=(Recordset1.Fields.Item("timestamp1").Value)%></span></td>
</tr>
<%
Repeat1__index++;
Recordset1.MoveNext();
}
%>
</table>
<p align="center">
<input name="Submit2" type="submit" value="Submit" />
</p>
</form>
</body>
</html>
<%
Recordset1.Close();
%>
<%
Recordset2.Close();
%>
<!--#include file="../../../Connections/lvcc.asp" -->
<%
var Recordset1 = Server.CreateObject("ADODB.Recordset");
Recordset1.ActiveConnection = MM_lvcc_STRING;
Recordset1.Source = "SELECT tblJanuary.SSN, tblJanuary.EOD, [tblJanuary.Last four], tblJanuary.firstname, tblJanuary.lastname, tblJanuary.ORGCODE, tblTollFreeEmployees.SCD, tblJanuary.SEID, tblJanuary.jan9, tblJanuary.extra2, tblJanuary.timestamp1 FROM tblJanuary, tblTollFreeEmployees WHERE [tblTollFreeEmployees.SEID] = [tblJanuary.SEID] and tblJanuary.jan9 LIKE ('R%') OR tblJanuary.jan9 LIKE ('R%') OR tblJanuary.jan9 LIKE ('2%') OR tblJanuary.jan9 LIKE ('2,%') OR tblJanuary.jan9 LIKE ('2, C%') OR tblJanuary.jan9 LIKE ('2, D%') ORDER BY tblJanuary.EOD, SCD, [Last Four]";
Recordset1.CursorType = 0;
Recordset1.CursorLocation = 2;
Recordset1.LockType = 1;
Recordset1.Open();
var Recordset1_numRows = 0;
arjan9 = new Array();
arSeid = new Array();
var f=new Enumerator(Request.Form);
var el;
var start;
var len;
var idx;
for (; !f.atEnd(); f.moveNext()) {
el = f.item().toString().toLowerCase();
start = el.indexOf("_");
if(start > -1) {
start++; len = el.length - start;
idx = parseInt(el.substr(start, len));
if(!isNaN(idx)) {
if(el.indexOf("jan9")!=-1) arjan9[idx] = Request.Form(el);
if(el.indexOf("seid")!=-1) arSeid[idx] = Request.Form(el);
}
}
}
for(var i=0;i<arSeid.length;i++) {
if(arjan9[i] && arSeid[i]) {
updateDB (arjan9[i], arSeid[i]);
}
else {
Response.Write("");
}
}
function updateDB(param_jan9, param_seid) {
var update = Server.CreateObject("ADODB.Command");
update.ActiveConnection = MM_lvcc_STRING;
update.CommandText = update.CommandText = "UPDATE tblJanuary SET jan9 = '" + param_jan9 + "' WHERE seid = '" + param_seid + "'";
update.CommandType = 1;
update.CommandTimeout = 0;
update.Prepared = true;
update.Execute();
}
var Repeat1__numRows = -1;
var Repeat1__index = 0;
Recordset1_numRows += Repeat1__numRows;
%>
<%
var Recordset2__MMColParam = "1";
if (String(Session("MM_Username")) != "undefined" &&
String(Session("MM_Username")) != "") {
Recordset2__MMColParam = String(Session("MM_Username"));
}
%>
<%
var Recordset2 = Server.CreateObject("ADODB.Recordset");
Recordset2.ActiveConnection = MM_lvcc_STRING;
Recordset2.Source = "SELECT LASTNAME, FIRSTNAME, SEID FROM Adminlogin WHERE SEID = '"+ Recordset2__MMColParam.replace(/'/g, "''") + "'";
Recordset2.CursorType = 0;
Recordset2.CursorLocation = 2;
Recordset2.LockType = 1;
Recordset2.Open();
var Recordset2_numRows = 0;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
<!--
function doCalcs(form1){
count = form1.lvavalbl.value;
for(x=0; x<document.getElementsByName('jan9').length; x++){
document.getElementsByName('jan9')[x].value = (count > 0) ? 'A' : 'D'
count --;
}
}
//-->
</script>
<style type="text/css">
<!--
body {
background-color: #0099FF;
}
.style8 {
font-size: 24px;
font-weight: bold;
}
-->
</style></head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>jan9</title>
<style type="text/css">
<!--
.style7 {font-size: 9px}
-->
</style>
</head>
<body>
<p align="right"><a href="Jan10approve.asp">Click here to continue to the next day. </a></p>
<p align="center"><span class="style9 style7">Approved by <%=(Recordset2.Fields.Item("FIRSTNAME").Value)%> <%=(Recordset2.Fields.Item("LASTNAME").Value)%></span></p>
<form method="post" id="form1" name="form1" action="">
<p align="center" class="style8">January 9th </P>
<p align="center">Input the amount of leave that can be given
<input name="lvavalbl" type="text" id="lvavalbl" size="2" onblur="doCalcs(form1)"/>
</P>
<table border="1" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td><span class="style7">ID</span></td>
<td><span class="style7">EOD</span></td>
<td><span class="style7">SCD</span></td>
<td><span class="style7">Last four</span></td>
<td><span class="style7">Firstname</span></td>
<td><span class="style7">Lastname</span></td>
<td><span class="style7">ORGCODE</span></td>
<td><span class="style7">SEID</span></td>
<td><span class="style7">Jan9</span></td>
<td><span class="style7">timestamp1</span></td>
</tr>
<% while ((Repeat1__numRows-- != 0) && (!Recordset1.EOF)) { %>
<tr>
<td><span class="style7"><%=(Recordset1.Fields.Item("SSN").Value)%></span></td>
<td><span class="style7"><%=(Recordset1.Fields.Item("EOD").Value)%></span></td>
<td><span class="style7"><%=(Recordset1.Fields.Item("SCD").Value)%></span></td>
<td><span class="style7"><%=(Recordset1.Fields.Item("Last four").Value)%></span></td>
<td><span class="style7"><%=(Recordset1.Fields.Item("firstname").Value)%></span></td>
<td><span class="style7"><%=(Recordset1.Fields.Item("lastname").Value)%></span></td>
<td><span class="style7"><%=(Recordset1.Fields.Item("ORGCODE").Value)%></span></td>
<td><input name="seid_<%=Repeat1__index%>" type="text" id="seid_<%=Repeat1__index%>" value="<%=(Recordset1.Fields.Item("SEID").Value)%>" size="5" maxlength="5" readonly="<%=(Recordset1.Fields.Item("SEID").Value)%>" /></td>
<td><input name="jan9_<%=Repeat1__index%>" type="text" id="jan9" value="<%=(Recordset1.Fields.Item("jan9").Value)%>" size="4" /></td>
<td><span class="style7"><%=(Recordset1.Fields.Item("timestamp1").Value)%></span></td>
</tr>
<%
Repeat1__index++;
Recordset1.MoveNext();
}
%>
</table>
<p align="center">
<input name="Submit2" type="submit" value="Submit" />
</p>
</form>
</body>
</html>
<%
Recordset1.Close();
%>
<%
Recordset2.Close();
%>