prasmile2002
Posts: 33 Joined: 2/14/2005 Status: offline
|
javascript help - 7/24/2006 12:58:13
Here is the code that I am working on..basically function L1,L2,L3 works fine, R2 doesn't the way I want to. I have spent a lot of time in this.. I am trying to navigate thru a record set L1 - moves a column to the left L2 -moves a page to the left L3 - Moves to the last record/latest record R1- moves a column to the right R2 - supposed to move page to the right but it's not.. That is where I am having a problem..instead it's moving to the last /latest record. ------------------------------------------ <html>
<head>
<title>footer</title>
<script language="javascript">
//Constants for the whole page
var pageSize = 7;
var OneRow = 1;
var FirstPageMin = 1;
var FirstPageMax = 7;
//Global variables for whole page
var clockID = 0;
function updateReportMaxRows(maxRow, ChartID){
var txtChartID = document.getElementById('txtChartID');
var txtReportMaxRow = document.getElementById('ReportMaxRow');
txtReportMaxRow.value = maxRow;
txtChartID.value = ChartID;
var txtMaxRow = document.getElementById('maxRow');
var txtMinRow = document.getElementById('minRow');
txtMaxRow.value = maxRow;
txtMinRow.value = (maxRow>pageSize)?(maxRow - pageSize + 1):1;
}
function submitClick(chartID, physician, display){
if ((chartID=="") || (physician=="")){
var msg = "<ul><li>ChartID and Physician are required fields</li></ul>";
parent.frames["main"].location="error.asp?msg=" + msg;
return;
}
var txtMaxRow = document.getElementById('maxRow');
var txtMinRow = document.getElementById('minRow');
txtMaxRow.value = -1;
txtMinRow.value = -1;
physician = (physician).toUpperCase();
parent.frames["main"].location="LabChartF.asp?ChartID=" + chartID + "&Physician=" +
physician + "&maxRow=" + txtMaxRow.value + "&minRow=" + txtMinRow.value;
}
function nextPage(minRow, maxRow){
var chartID = document.getElementById('txtChartID');
if (chartID==""){
var msg = "<ul><li>ChartID are required fields</li></ul>";
parent.frames["main"].location="error.asp?msg=" + msg;
return;
}
//alert("LabChartFCH.asp?ChartID=" + chartID.value + "&Physician=" +
// "&maxRow=" + maxRow + "&minRow=" + minRow);
parent.frames["main"].location="test.asp?ChartID=" + chartID.value + "&Physician=" +
"&maxRow=" + maxRow + "&minRow=" + minRow;
}
function L1_Click(){
var txtMaxRow = document.getElementById('maxRow');
var txtMinRow = document.getElementById('minRow');
if(parseInt(txtMinRow.value) > 1){
txtMinRow.value = parseInt(txtMinRow.value) - parseInt(OneRow);
txtMaxRow.value = parseInt(txtMaxRow.value) - parseInt(OneRow);
}else{
if (parseInt(txtMinRow.value) == -1){
alert("Please click Submit before click on L button");
}else
alert("You have reached the first page of the report");
return;
}
nextPage(txtMinRow.value,txtMaxRow.value);
}
function L2_Click(){
var txtMaxRow = document.getElementById('maxRow');
var txtMinRow = document.getElementById('minRow');
if(parseInt(txtMinRow.value) > 1){
txtMinRow.value = parseInt(txtMinRow.value) - parseInt(pageSize);
txtMaxRow.value = parseInt(txtMaxRow.value) - parseInt(pageSize);
if(parseInt(txtMinRow.value) < 0){
txtMinRow.value = FirstPageMin;
txtMaxRow.value = FirstPageMax;
}
}else{
if (parseInt(txtMinRow.value) == -1){
alert("Please click Submit before clicking on L button");
}else
alert("You have reached the first page of the report");
return;
}
nextPage(txtMinRow.value,txtMaxRow.value);
}
/*function L3_Click(){
var txtMaxRow = document.getElementById('maxRow');
var txtMinRow = document.getElementById('minRow');
if (txtMinRow.value == -1){
alert("Please click Submit before clicking on L button");
return;
}
if (txtMinRow.value == 1){
alert("You have reached the first page of the report");
return;
}
txtMinRow.value = FirstPageMin;
txtMaxRow.value = FirstPageMax;
nextPage(txtMinRow.value,txtMaxRow.value);
}*/
function L3_Click(){
var txtReportMaxRow = document.getElementById('ReportMaxRow');
var txtMaxRow = document.getElementById('maxRow');
var txtMinRow = document.getElementById('minRow');
if (parseInt(txtMinRow.value) == -1){
alert("Please click Submit before clicking on R button");
return;
}
if (parseInt(txtMaxRow.value) == parseInt(txtReportMaxRow.value)){
alert("You have reached the last page of the report");
return;
}
txtMinRow.value = (parseInt(txtReportMaxRow.value) > parseInt(pageSize))?(parseInt(txtReportMaxRow.value) - parseInt(pageSize) + 1):txtReportMaxRow.value;
txtMaxRow.value = txtReportMaxRow.value;
nextPage(txtMinRow.value,txtMaxRow.value);
}
function R1_Click(){
var txtReportMaxRow = document.getElementById('ReportMaxRow');
var txtMaxRow = document.getElementById('maxRow');
var txtMinRow = document.getElementById('minRow');
var temp = parseInt(txtReportMaxRow.value);
var temp2 = parseInt(txtMaxRow.value);
var minTemp = parseInt(txtMinRow.value);
if ((txtMinRow.value > -1) && (temp2 < temp)){
temp2 += parseInt(OneRow);
minTemp += parseInt(OneRow);
txtMinRow.value = minTemp;
txtMaxRow.value = temp2;
}else{
if (txtMinRow.value == -1){
alert("Please click Submit before clicking on R button");
}else
alert("You have reached the last page of the report");
return;
}
nextPage(txtMinRow.value,txtMaxRow.value);
}
function R2_Click(){
var txtReportMaxRow = document.getElementById('ReportMaxRow');
var txtMaxRow = document.getElementById('maxRow');
var txtMinRow = document.getElementById('minRow');
var temp = parseInt(txtReportMaxRow.value);
var temp2 = parseInt(txtMaxRow.value);
if ((parseInt(txtMinRow.value) > -1) && (temp2 < temp)){
txtMinRow.value += parseInt(pageSize);
txtMaxRow.value += parseInt(pageSize);
if(parseInt(txtMaxRow.value) > parseInt(txtReportMaxRow.value)){
txtMinRow.value = parseInt(txtReportMaxRow.value) - parseInt(pageSize) + 1;
txtMaxRow.value = txtReportMaxRow.value;
}
}else{
if (txtMinRow.value == -1){
alert("Please click Submit before clicking on R button");
}else{
alert("You have reached the last page of the report");
}
return;
}
nextPage(txtMinRow.value,txtMaxRow.value);
}
/*function R3_Click(){
var txtReportMaxRow = document.getElementById('ReportMaxRow');
var txtMaxRow = document.getElementById('maxRow');
var txtMinRow = document.getElementById('minRow');
if (txtMinRow.value == -1){
alert("Please click Submit before clicking on R button");
return;
}
if (txtMaxRow.value == txtReportMaxRow.value){
alert("You have reached the last page of the report");
return;
}
txtMinRow.value = (txtReportMaxRow.value > pageSize)?(txtReportMaxRow.value - pageSize):txtReportMaxRow.value;
txtMaxRow.value = txtReportMaxRow.value;
nextPage(txtMinRow.value,txtMaxRow.value);
}*/
function R3_Click(){
var txtReportMaxRow = document.getElementById('ReportMaxRow');
var txtMaxRow = document.getElementById('maxRow');
var txtMinRow = document.getElementById('minRow');
if (parseInt(txtMinRow.value) == -1){
alert("Please click Submit before clicking on L button");
return;
}
if (parseInt(txtMinRow.value) == 1){
alert("You have reached the first page of the report");
return;
}
txtMinRow.value = FirstPageMin;
if (parseInt(FirstPageMax) > parseInt(txtReportMaxRow.value)){
txtMaxRow.value = txtReportMaxRow.value;
}else{
txtMaxRow.value = FirstPageMax;
}
nextPage(txtMinRow.value,txtMaxRow.value);
}
function RefreshDateTime(){
if(clockID) {
clearTimeout(clockID);
clockID = 0;
}
var thetime= new Date();
var nhours=thetime.getHours();
var nmins=thetime.getMinutes();
var nsecn=thetime.getSeconds();
var AorP=" ";
if (nhours>=12)
AorP="PM";
else
AorP="AM";
if (nhours>=13)
nhours-=12;
if (nhours==0)
nhours=12;
if (nsecn<10)
nsecn="0"+nsecn;
if (nmins<10)
nmins="0"+nmins;
var divCtrl = document.getElementById('divDateTime');
divCtrl.innerHTML = nhours+":"+nmins+":"+nsecn+" "+AorP;
clockID = setTimeout("RefreshDateTime()", 1000);
}
function DateDisplay(){
var thetime=new Date();
var nhours=thetime.getHours();
var nmins=thetime.getMinutes();
var nsecn=thetime.getSeconds();
var nday=thetime.getDay();
var nmonth=thetime.getMonth();
var ntoday=thetime.getDate();
var nyear=thetime.getYear();
var AorP=" ";
if (nhours>=12)
AorP="P.M.";
else
AorP="A.M.";
if (nhours>=13)
nhours-=12;
if (nhours==0)
nhours=12;
if (nsecn<10)
nsecn="0"+nsecn;
if (nmins<10)
nmins="0"+nmins;
var dayName = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
nday = dayName[nday];
nmonth+=1;
if (nyear<=99)
nyear= "19" + nyear;
if ((nyear>99) && (nyear<2000))
nyear += 1900;
document.write(nday+", "+nmonth+"/"+ntoday+"/"+nyear);
//document.write(nhours+": "+nmins+": "+nsecn+" "+AorP+" "+nday+", "+nmonth+"/"+ntoday+"/"+nyear);
}
</script>
</head>
<body>
<script language=javascript>
//Want the time running
window.setTimeout('RefreshDateTime()',1000);
</script>
<table cellpadding="0" cellspacing="0" width=100%>
<tr>
<td width="139" align=center valign=top>
<script language=javascript>DateDisplay();</script>
<font face="Arial" size="2"><br>
</font>
<strong><font size="2"><a href=javascript:L3_Click();>
<font face="Arial"><<<L3</font></a><font face="Arial"> <a href=javascript:L2_Click();><<L2</a>
<a href=javascript:L1_Click();><L1</a></font></font></strong><font face="Arial" size="2">
</font>
</td>
<td width="672" align=center>
<form method="POST" action="">
<!--table cellpadding="1" cellspacing="1" width=437>
<tr bgcolor=#336699>
<th height="26" width="112">
<font color="#FFFFFF" face="Arial" size="2">Chart ID</font></th>
<th height="26" width="95">
<font color="#FFFFFF" face="Arial" size="2">Physician</font></th>
<th height="26" width="101">
<font color="#FFFFFF" face="Arial" size="2">Displacement (L1,L2, L3
or R1,R2, R3)</font></th>
<td height="26" bgcolor=#FFFFFF align=center width="116"></td>
</tr>
<tr bgcolor=#EEEEEE align=center valign=middle>
<td width="112"><font face="Arial"><input type="text" name="txtChartID" size="12"></font></td>
<td width="95"><font face="Arial"><input type="text" name="txtPhysician" size="10"></font></td>
<td width="101"><font face="Arial"><input type="text" name="txtDisplay" size="7"></font></td>
<td bgcolor=#FFFFFF width="116"><font face="Arial"><input type="button" value="Submit" name="B1" onclick="submitClick(txtChartID.value,txtPhysician.value,txtDisplay.value);"><input type="reset" value="Reset" name="B2"></font></td>
</tr>
</table-->
<font face="Arial">
<INPUT type="hidden" name=maxRow id=maxRow value=-1>
<INPUT type="hidden" name=minRow id=minRow value=-1>
<INPUT type="hidden" name=txtChartID id=txtChartID>
<INPUT type="hidden" name=ReportMaxRow id=ReportMaxRow value=-1>
</font>
</form>
</td>
<td width="174" align=center valign=top><div id=divDateTime></div>
<font size="2"><strong><a href=javascript:R1_Click();><font face="Arial">R1></font></a><font face="Arial"> <a href=javascript:R2_Click();> R2>></a> <a href=javascript:R3_Click();> R3>>></a>
</font></strong></font></td>
</tr>
<tr valign=top>
<td width="139"></td>
<td align=center>
</td>
<td width="174"></td>
</tr>
</table>
</body>
</html>
|