Refresh Div Only No Scroll
I've been trying to refresh a certain div tag only I tried AJAX but I can't use that because there is no source file to pull fro it is pulling it from a database program(the data t
Solution 1:
Possibly, this will solve your problem (source):
$('#result').load('ajax/test.html #container');
When this method executes, it retrieves the content of ajax/test.html, but then jQuery parses the returned document to find the element with an ID of container. This element, along with its contents, is inserted into the element with an ID of result, and the rest of the retrieved document is discarded.
Let's say you only have 'a.html' and the id of your div is 'divId', you would need to place in your refresh() function:
$('#divId').load('a.html #divId');
EDIT
the code then should be (placed javascript functions inside the div and changed 'refresh' function):
<!DOCTYPE htmlPUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><styletype="text/css">body {
background-image: url('../Images/Black-BackGround.gif');
background-repeat: repeat;
}
bodytd {
font-Family: Arial;
font-size: 12px;
}
#Nava {
position:relative;
display:block;
text-decoration: none;
color:black;
}
</style><scriptsrc="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script><scripttype="text/javascript">setInterval( functionrefresh()
{
$('#toptable').load('0355.htm #toptable');
}, 1500);
</script></head><body><divid="toptable"align="center"><SCRIPTtype="text/javascript"src="../Images/jsdate.js"></script><SCRIPTtype="text/javascript">functionJump(s){ window.location.href = s ;}</SCRIPT><scripttype="text/javascript">//====================================================================================================================// Date Difference//====================================================================================================================functionGetDiff (dt) {
sMins = " Min";
sHours = " Hrs";
sDays = " Days";
sSecs = " Secs";
if ( Math.abs (DateDiff ("s", now, dt)) < 86400 ) {
if ( Math.abs (DateDiff ("s", now, dt)) <= 3600 ) {
return ((Math.floor(Math.abs (DateDiff ("s", now, dt)/60)*100)/100).toFixed(2) + sMins);
}
else
{
return ((Math.floor(Math.abs (DateDiff ("s", now, dt)/3600)*100)/100).toFixed(2) + sHours);
}
}
else
{
return ((Math.floor(Math.abs (DateDiff ("s", now, dt)/86400)*100)/100).toFixed(2) + sDays);
}
}
//====================================================================================================================// Function Draw Row//====================================================================================================================</script><scripttype="text/javascript">
function DrawRow ( link,Status,Value,ResultName,DateTime,LSL,OPT,USL,LCL,UCL,LO1L,UO1L,LO2L,UO2L,CpK,CP,PPK,PP,TestDue,TestLate,ExpNeeded,ExpLate,AddsNeeded,AddsLate,Count,ActiveCount,Dummy1,ReviewedBy,TestID,ItemID,Dummy2,Test1,Test2,Test3,Test4,Test5,T1,T2,S ) {
s = "#008A00";
now = new Date();
//====================================================================================================================
// Color Coding For Results
//====================================================================================================================
if ( (Number (Status) & 1073741824) > 0 ) {
s = "#C0C0C0";
a = "center";
h = "22";
cr = "#000000";
sz = "2";
}
else
{
a = "left";
h = "22";
sz = "1";
cr = "#000000";
if ( DateDiff ("n", DateTime, "01/01/1980 00:00") == 0 ) {
Value = "Not-Tested";
DateTime = "Not Tested";
ResultName = ResultName + " - Needs To Be Tested";
}
}
if (( Number(Status) & 4) > 0 ) { s = "#0000FF"; cr = "#FFFFFF"; }
if (( Number(Status) & 32) > 0 ) { s = "#52CC29"; cr = "#000000"; }
if (( Number(Status) & 16) > 0 ) { s = "#FF4D94"; cr = "#000000"; }
if (( Number(Status) & 2) > 0 ) { s = "#FFFF00"; cr = "#000000"; }
if (( Number(Status) & 1) > 0 ) { s = "#E80000"; cr = "#FFFF00"; }
if (( Number(Status) & 8) > 0 ) { s = "#FF6600"; cr = "#000000"; }
if (( Number(Status) & 0) > 0 ) { s = "008A00"; cr = "#000000"; }
//====================================================================================================================
// Test Status Timing
//====================================================================================================================
ReviewIcon = "<palign='center'width='20'height='21'><fontsize='1'> </font>";
Dummy2 = "<b><palign='center'width='20'height='21'><fontsize='1'> </font></b>";
if ( Number(ActiveCount) != -1 ) {
sz = "1";
a = "left";
h = "22";
if ( TestDue > "" && TestLate > "" ) {
duedif = DateDiff ("s", TestDue, now);
if ( DateDiff ("s", TestDue, now) >= 0.0 ) { ReviewIcon = "<imgsrc='../Images/Green-Test.png'width='20'height='21'>"; Dummy2 ="<strong><fontsize='"+sz+"'color = "+cr+">Due In " + GetDiff (TestLate);}
else
{
duedif = Math.abs (duedif);
if ( duedif < 3600 ) { duestg = String(Number(Math.floor((duedif/60)*100)/100).toFixed(2)) + " Min"; }
if (( duedif < 86400 ) && ( duedif >= 3600 )) { duestg = String(Number(Math.floor((duedif/3600)*100)/100).toFixed(2)) + " Hrs"; }
if ( duedif >= 86400 ) { duestg = String(Number(Math.floor((duedif/86400)*100)/100).toFixed(2)) + " Days"; }
Dummy2= "<palign='center'width='20'height='22'><b><fontsize='1'color = "+cr+">Start In " + duestg + "</font></b>";
ReviewIcon="<imgsrc='../Images/Blue-Test.png'width='20'height='21'>";
}
}
if ( TestLate > "" ) {
if ( DateDiff ("s", TestLate, now) >= 0 ) { ReviewIcon = "<imgsrc='../Images/Red-Test.png'width='20'height='21'>"; Dummy2 = "<strong><fontsize='1'color = "+cr+">Late By " + GetDiff (TestLate);}
}
if ( TestDue <="" ) {ReviewIcon="<imgsrc='../Images/Not-Scheduled.png'width='20'height='21'>"; Dummy2 = "<b><fontsize='"+sz+"'color = "+cr+">Not Scheduled";
}
if ( Number(ActiveCount) < Number(Count) ) {ReviewIcon= "<imgsrc='../Images/GrayAstris.png'width='20'height='21'>"; Dummy12 = "<strong><fontsize='"+sz+"'color = "+cr+">Deactivated";
}
}
//====================================================================================================================
// Date-Time Format
//====================================================================================================================
fmtDateTime = DateTime;
if ( IsDate(DateTime) ) {
mnth = DatePart ("m", DateTime);
dy = DatePart ("d", DateTime);
yr = DatePart ("yyyy", DateTime); // full four-digit year
yr2 = DatePart ("yyyy", DateTime)-2000; //should provide last two-digits of year
hrs = DatePart ("h", DateTime);
mn = DatePart ("n", DateTime);
sc = DatePart ("ss", DateTime);
if ( mnth.toString().length == 1 ) { mnth = "0" + mnth; }
if ( dy.toString().length == 1 ) { dy = "0" + dy; }
if ( mn.toString().length == 1 ) { mn = "0" + mn; }
ampm = "am";
//bug#604
if ( Number(hrs) >= 12 ) {
ampm = "pm";
if (Number(hrs) >= 13) {
hrs = String(Number(hrs) - 12);
}
}
fmtDateTime = (String(mnth) + "/" + String(dy) + "/" + String(yr2) + " " + String(hrs) + ":" + String(mn) + " " + String(ampm));
}
//====================================================================================================================
// Draw Result Name
//====================================================================================================================
document.write( "<trbgcolor='"+s+"'height='"+h+"' >" );
document.write( "<tdbgcolor='#000000'width='2%'height='21' >"+ReviewIcon+"</td>" );
document.write( "<td "+link+" width='134'height='22'><palign='center'><b>"+Dummy2+"</b></font></td>" );
document.write( "<td "+link+" width='55'><palign='center'><b><fontsize='"+sz+"'color='"+cr+"'>"+Value+"</font></td>");
document.write( "<td "+link+" width='243'><palign='"+a+"'><strong><fontsize='"+sz+"'color='"+cr+"'> "+ResultName+" </strong></font></td>" );
document.write( "<td "+link+" width='100'><palign='center'><b><fontsize='"+sz+"'color='"+cr+"'>"+ fmtDateTime +"</strong></font></td>" );
document.write( "<td "+link+" width='52'><palign='center'><b><fontsize='"+sz+"'color='"+cr+"'> "+LSL+" </font></td>" );
document.write( "<td "+link+" width='52'><palign='center'><b><fontsize='"+sz+"'color='"+cr+"'> "+OPT+" </font></td>" );
document.write( "<td "+link+" width='52'><palign='center'><b><fontsize='"+sz+"'color='"+cr+"'> "+USL+" </font></td>" );
document.write( "<td "+link+" width='54'><palign='center'><b><fontsize='"+sz+"'color='"+cr+"'> "+LCL+" </font></td>" );
document.write( "<td "+link+" width='54'><palign='center'><b><fontsize='"+sz+"'color='"+cr+"'> "+UCL+" </font></td>" );
document.write( "<td "+link+" width='56'><palign='center'><b><fontsize='"+sz+"'color='"+cr+"'> "+CpK+" </font></td>" );
document.write( "</tr>" );
}
//====================================================================================================================
// Function Draw Add Row
//====================================================================================================================
function DrawAddRow ( link,Status,Action,Amount,Unit,Consumable,DueBy,TestReportID,Dummy1,SignedOff,TestID,ItemID,Dummy2,DateTme ) {
if ( SignedOff == 0 ) {
s = "#008A00";
cr = "#000000";
sz = "2";
if ( (Number(Status) & 1073741824) > 0 ){
s = "#C0C0C0";
a = "center";
h = "22";
cr = "#000000";
SignOffIcon = " ";
}
else
//====================================================================================================================
// Add Status
//====================================================================================================================
{
a = "left";
h = "18";
sz = "1";
if ( DueBy > "" ) {
if ( DateDiff("n", now, DueBy) >= 0 ) { s = "#008A00"; cr="#000000"; Dummy2 = "<b><fontsize='"+sz+"'color = "+cr+">Due In " + GetDiff (DueBy); Dummy1 = "<imgsrc='../Images/Green-Test2.png'width='20'height='18'>";}
if ( DueBy > "" ) {
if ( DateDiff("n", DueBy, now) >= 0 ) { s = "#E80000"; cr="#FFFF00"; Dummy2 = "<b><fontsize='"+sz+"'color = "+cr+">Late By " + GetDiff (DueBy); Dummy1 = "<imgsrc='../Images/Red-Test2.png'width='20'height='18'>";}
}
}
}
//====================================================================================================================
// Draw Add Row
//====================================================================================================================
document.write( "<trbgcolor='"+s+"'height='"+h+"' >" );
document.write( "<tdwidth='2%' ><palign='center'><B><fontsize='"+sz+"'color='"+cr+"'>"+Dummy1+"</td>" );
document.write( "<tdwidth='16%' ><palign='center'><B><fontsize='"+sz+"'color='"+cr+"'>"+Dummy2+"</td>" );
document.write( "<tdwidth=32%'><palign='center'><b><fontsize='"+sz+"'color='"+cr+"'> "+Consumable+" </font></td>" );
document.write( "<tdwidth='9%'><palign='center'><b><fontsize='"+sz+"'color='"+cr+"'>"+Action+"</font></td>");
document.write( "<tdwidth='10%'><palign='center'><b><fontsize='"+sz+"'color='"+cr+"'>"+Amount+"</font></td>");
document.write( "<tdwidth='7%'><palign='center'><b><fontsize='"+sz+"'color='"+cr+"'>"+Unit+"</font></td>" );
document.write( "<tdwidth='13%'><palign='center'><b><fontsize='"+sz+"'color='"+cr+"'>"+DueBy+"</font></td>" );
document.write( "<tdwidth='10%'><palign='center'><b><fontsize='"+sz+"'color='"+cr+"'>"+TestReportID+"</font></td>" );
document.write( "</tr>" );
}
}
function DrawRow2 ( link,Status,Value,ResultName,DateTime,LSL,OPT,USL,LCL,UCL,LO1L,UO1L,LO2L,UO2L,CpK,CP,PPK,PP,TestDue,TestLate,ExpNeeded,ExpLate,AddsNeeded,AddsLate,Count,ActiveCount,Dummy1,ReviewedBy,TestID,ItemID,Dummy2,Test1,Test2,Test3,Test4,Test5,T1,T2,S ) {
s = "#008A00";
now = new Date();
//====================================================================================================================
// Color Coding For Results
//====================================================================================================================
if ( (Number (Status) & 1073741824) > 0 ) {
s = "#C0C0C0";
a = "center";
h = "22";
cr = "#000000";
sz = "2";
}
else
{
a = "left";
h = "22";
sz = "1";
cr = "#000000";
if ( DateDiff ("n", DateTime, "01/01/1980 00:00") == 0 ) {
Value = "<imgsrc='../Images/Not-Tested.png'width='53'height='23'>";
DateTime = "Not Tested";
ResultName = ResultName + " - Needs To Be Tested";
}
}
if (( Number(Status) & 2) > 0 ) { s = "#FFFF00"; cr = "#000000"; }
if (( Number(Status) & 1) > 0 ) { s = "#E80000"; cr = "#FFFF00"; TestIcon = "FFFF00" }
document.write( "<trbgcolor='"+s+"'height='"+h+"' >" );
document.write( "<td "+link+" width='245'><palign='"+a+"'><b><fontsize='"+sz+"'color='"+cr+"'> "+ResultName+" </font></td>" );
document.write( "<td "+link+" width='50'><palign='center'><b><fontsize='"+sz+"'color='"+cr+"'> "+L01L+" </font></td>" );
document.write( "<td "+link+" width='50'><palign='center'><b><fontsize='"+sz+"'color='"+cr+"'> "+L01U+" </font></td>" );
document.write( "<td "+link+" width='50'><palign='center'><b><fontsize='"+sz+"'color='"+cr+"'> "+PpK+" </font></td>" );
document.write( "<td "+link+" width='50'><palign='center'><b><fontsize='"+sz+"'color='"+cr+"'> "+PpK+" </font></td>" );
document.write( "<td "+link+" width='52'><palign='center'><b><fontsize='"+sz+"'color='"+cr+"'> "+Pp+" </font></td>" );
document.write( "<td "+link+" width='52'><palign='center'><b><fontsize='"+sz+"'color='"+cr+"'> "+Cp+" </font></td>" );
document.write( "</tr>" );
}
</script><tableborder="0"width="850"id="Nav"cellpadding="0"cellspacing="0"valign="top"><tr><tdstylE="float:none; height:60; width:850px; align:center;"><TABLEstyle="float:left;border:5px; border-style:outset;border-color:#E80000; height:20px; width:23%; border-spacing:0; border-collapes:collapse;"><TRStyle="background-color:#595959;color:FFFF00;"><THStyle="border:1px solid #FFFF00;font-size:12px; width:45;height:20;"><divstyle="text-align:center; margin-bottom:-1px;"> Symbol </TH><THStyle="border:1px solid #FFFF00;font-size:12px; width:125;height:20;"><divstyle="text-align:center; margin-bottom:-1px;">Meaning</TH></TR><TR><TDstyle="background-color:#000000;color:FFFF00; border:1px solid #FFFF00;background-image: url(../Images/Not-Scheduled.png); background-size:22px 24px; width:25; height:24; background-repeat:no-repeat; background-position:center;"></TD><TDstyle="background-color:#000000; color:FFFF00; border:1px solid #FFFF00; font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;">Not Scheduled</TD></TR><TR><TDstyle="background-color:#000000;color:FFFF00; border:1px solid #FFFF00;background-image: url(../Images/Gray-Astris3.png); background-size:22px 24px; width:25; height:24; background-repeat:no-repeat; background-position:center;"></TD><TDstyle="background-color:#000000; color:FFFF00; border:1px solid #FFFF00; font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;"> Deactivated Tanks </TD></TR><TR><TDstyle="background-color:#000000;color:FFFF00; border:1px solid #FFFF00;background-image: url(../Images/Blue-Test.png); background-size:22px 24px; width:25; height:24; background-repeat:no-repeat; background-position:center;"></TD><TDstyle="background-color:#000000; color:FFFF00; border:1px solid #FFFF00; font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;">Test Scheduled</TD></TR><TR><TDstyle="background-color:#000000;color:FFFF00; border:1px solid #FFFF00;background-image: url(../Images/Green-Test.png); background-size:22px 24px; width:22; height:24; background-repeat:no-repeat; background-position:center;"></TD><TDstyle="background-color:#000000; color:FFFF00; border:1px solid #FFFF00; font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;">Test In Process</TD></TR><TR><TDstyle="background-color:#000000;color:FFFF00; border:1px solid #FFFF00;background-image: url(../Images/Red-Test.png); background-size:22px 24px; width:22; height:24; background-repeat:no-repeat; background-position:center;"></TD><TDstyle="background-color:#000000; color:FFFF00; border:1px solid #FFFF00; font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;">Test Late</TD></TR></TABLE><divalign="center"><imgstyle="float:none; margin-left:auto; margin-right:auto; margin-top:17px; border:10px ridge #E80000; width:199; height:101;"src="../Images/Logo.jpg" /><TABLEstyle="float:right;border:5px; border-style:outset;border-color:#E80000; height:20px; width:23%; border-spacing:0; border-collapes:collapse;"><TRStyle="background-color:#595959;color:FFFF00;"><THStyle="border:1px solid #FFFF00;font-size:12px; width:125;height:20;"><divstyle="text-align:center; margin-bottom:-1px;">Meaning</TH><THStyle="border:1px solid #FFFF00;font-size:12px; width:45;height:20;"><divstyle="text-align:center; margin-bottom:-1px;"> Symbol </TH></TR><TR><TDstyle="background-color:#000000; color:FFFF00; border:1px solid #FFFF00; font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;">Not Scheduled</TD><TDstyle="background-color:#000000;color:FFFF00; border:1px solid #FFFF00;background-image: url(../Images/Not-Scheduled.png); background-size:22px 24px; width:25; height:24; background-repeat:no-repeat; background-position:center;"></TD></TR><TR><TDstyle="background-color:#000000; color:FFFF00; border:1px solid #FFFF00; font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;"> Deactivated Tanks </TD><TDstyle="background-color:#000000;color:FFFF00; border:1px solid #FFFF00;background-image: url(../Images/Gray-Astris3.png); background-size:22px 24px; width:25; height:24; background-repeat:no-repeat; background-position:center;"></TD></TR><TR><TDstyle="background-color:#000000; color:FFFF00; border:1px solid #FFFF00; font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;">Test Scheduled</TD><TDstyle="background-color:#000000;color:FFFF00; border:1px solid #FFFF00;background-image: url(../Images/Blue-Test.png); background-size:22px 24px; width:25; height:24; background-repeat:no-repeat; background-position:center;"></TD></TR><TR><TDstyle="background-color:#000000; color:FFFF00; border:1px solid #FFFF00; font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;">Test In Process</TD><TDstyle="background-color:#000000;color:FFFF00; border:1px solid #FFFF00;background-image: url(../Images/Green-Test.png); background-size:22px 24px; width:22; height:24; background-repeat:no-repeat; background-position:center;"></TD></TR><TR><TDstyle="background-color:#000000; color:FFFF00; border:1px solid #FFFF00; font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;">Test Late</TD><TDstyle="background-color:#000000;color:FFFF00; border:1px solid #FFFF00;background-image: url(../Images/Red-Test.png); background-size:22px 24px; width:22; height:24; background-repeat:no-repeat; background-position:center;"></TD></TR></td></tr></div><divid="description>
<table>
<tr>
<td style="height:5px; text-align:center;"></td></tr></table><tablestyle="border-style:none; width:850px: height:73px; border-spacing:0; border-collapse:collapse; vertical-align:top; text-align:center;"><tr><TDstyle="background-color:#000000;color:FFFF00; height:20px; text-align:center; font-face:arial; font-size:24px; font-weight:bold;">IEC's TrueLogic Dashboard</td></tr></div><divid="group"><table><tr><tdstyle="height:4px; text-align:center;"></td></tr></table><tablestyle="border-style:none; width:850px: height:73px; border-spacing:0; border-collapse:collapse; vertical-align:top; text-align:center;"><tdstyle="height:20px; text-align:center;"></td><TDstyle="background-color:#000000;color:FFFF00; height:24px; text-align:center; font-face:arial; font-size:20px; font-weight:normal;">[GroupName]</td></div><divid="object"><table><tr><tdstyle="height:4px; text-align:center;"></td></tr></table><tablestyle="border-style:none; width:850px; border-spacing:0; border-collapse:collapse; vertical-align:top;"><tdstyle="float:left;width:5;"><ahref=[BackLink]><imgborder="0"src="../Images/Back-ButtonB.gif"width="80"height="18"></td><TDstyle="text-align:center; background-color:#000000;color:FFFF00; height:20px; font-face:arial; font-size:18px; font-weight:bold;">[ObjectName]</td><tdstyle="width:26px;"></table></div><divid="drawrow"align="center"><table><tr><tdstyle="height:8px;"></td></tr></table><TABLEstyle="float:center;border:5px; border-style:outset;border-color:#E80000; width:850px; height:18px; border-spacing:0; border-collapes:collapse;"tableborder="1"><scripttype="text/javascript">
DrawRow ("","1073741824","<b>Value</B>","<b>Result Name</b>","<b>Date - Time</b>","<b>LSL</b>","<b>Opt.</b>","<b>USL</b>","<b>LCL</b>","<b>UCL</b>","<b>LO1L</b>","<b>UO1L</b>","<b>LO2L</b>","<b>UO2L</b>","<b>CpK</b>","Cp","<b>Ppk</b>","<b>PP</b>","<b>ItemID</b>","Dummy1","Dummy2","Dummy3","Dummy4","Dummy5",1,-1,"Dummy6",1,0,0,"Dummy7");
[ItemsHTML]</script></table><table><tr><tdstyle="height:20px;"></td></tr></table><TABLEstyle="float:center;border:5px; border-style:outset;border-color:#E80000; width:850px; border-spacing:0; border-collapes:collapse;"tableborder="1"><divid="addrow"><scripttype="text/javascript">DrawAddRow ("","1073741824","Action","Amount","Units","Chemical Additive","Due By","Report ID","","","0","0","Due Status");
[AddItemsHTML]</script></div></table><table><tr><tdstyle="height:20px;"></td></tr></table><table><tr><tdstyle="height:10px;"></td></tr></table><table><tr><tdstyle="height:5px;"></td></tr></table></div><divid="signoff"align="center"><tablestyle="border-style:none; width:850px; border-spacing:0; border-collapse:collapse; vertical-align:top;"><tdstyle="height:25px;"><tablestyle="border-style:none; width:850px; border-spacing:0; border-collapse:collapse;"><tr><TDstyle="background-color:#000000;color:FFFF00;bwidth:335px; text-align:left; font-size:10;">By TrueLogic Company Edited By International Electronic Components</td><tdwidth="290"></td><TDstyle="background-color:#000000;color:FFFF00; bwidth:135px; text-align:right; font-size:10;">[LastBuild]</td></tr></table><tr><tdstyle="height:25px;"></td></td></div></tr></table></div></body></html>
Post a Comment for "Refresh Div Only No Scroll"