Hello all:
We are attempting to use JS to maintain the scroll position of a DIV upon postback of a standard FORM. There are several solutions online for ASP, PHP, etc... however we code in a proprietary CGI construct, thus those solutions have not worked for us.
I found this script on your page, written several years ago by Eric Pascarello (see below). It works
perfectly for what we are trying to accomplish, less one major issue - it writes to a cookie, and we need it to write to a hidden field.
Through course of full disclosure, I am a software engineer and fairly well versed in various forms of scripting - however, I am embarrassingly TERRIBLE at JS. I am sure the solution is simple, and staring me in the face, but I am not sure what to change.
<script type="text/javascript">
window.onload = function(){
var strCook = document.cookie;
if(strCook.indexOf("!~")!=0){
var intS = strCook.indexOf("!~");
var intE = strCook.indexOf("~!");
var strPos = strCook.substring(intS+2,intE);
document.getElementById("'+divTest4+'").scrollTop = strPos;
}
}
function SetDivPosition(){
var intY = document.getElementById("'+divTest4+'").scrollTop;
document.title = intY;
document.cookie = "yPos=!~" + intY + "~!";
}
</script>
<div id="'+divTest4+'" onscroll="SetDivPosition()" style="width:150px;height:200px;overflow:auto">
1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>
1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>
1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>
1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>
ERIC<br/>
1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>
1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>
1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>
1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>
</div>
Thanks in advance to anyone who can help.
G.C. Hutson
Sadien Intellectual Property
gch@sadien.com
(615) 869-0022 x 8100