This topic is locked
[SOLVED]

 Auto Save almost working but need Java guru

3/29/2012 2:25:33 PM
PHPRunner General questions
A
Athlon author

Im sure there are other ways to do this, but I like the display of time remaining on the page, Other than I can not get it to actually save the record - its great.

What is the actual function that the save triggers in PHPrunner?
Firstly thank you to anyone that can finish this. Every 25 seconds it auto saves the record. It displays in a window on the edit page the time remaining and seems to work great - Only I do not know how to fire the save record event without using the save button. Looking through posts there have been many asking for this so I think it would be useful for lots of other users to have something they can use or modify. I know very little Java and have been unsuccessful in finishing it. The original script came from another site free to use - is not my work :-)
I compiled the following into a .js file, added html in header and body of the page, redirect works but I need it actually save the record.
Anyone .. Please :-)
JS file code:
var mnAutoSaveMilliSeconds=0;

var mnAutoSaveMilliSecondsExp=0;

var mnAutoSaveInterval=30000;
function AutoSaveInit(nMilliSeconds)

{
try

{
var nMinutes=0;
AutoSaveClearTimeOuts();
nMinutes = ((nMilliSeconds / 1000) / 60);

mnAutoSaveMilliSeconds = nMilliSeconds;

mnAutoSaveMilliSecondsExp=0;
oTimeOut = window.setTimeout("AutoSaveSubmit()",nMilliSeconds);

oInterval = window.setInterval("AutoSaveCountDown()",mnAutoSaveInterval);

document.getElementById("divAutoSave").innerHTML = "<b>Auto Save In " + nMinutes + " Minutes</b>";
}

catch (exception)

{

if (exception.description == null) { alert("AutoSaveInit Error: " + exception.message); }

else { alert("AutoSaveInit Error: " + exception.description); }

}

}
function AutoSaveCountDown()

{
var nMinutesLeft=0;

var nMilliSecondsLeft=0;
mnAutoSaveMilliSecondsExp = mnAutoSaveMilliSecondsExp + mnAutoSaveInterval;
if ( mnAutoSaveMilliSeconds > mnAutoSaveMilliSecondsExp)

{

nMilliSecondsLeft = mnAutoSaveMilliSeconds - mnAutoSaveMilliSecondsExp;

nMinutes= AutoSaveRoundNumber(((nMilliSecondsLeft / 1000) / 60),2);

document.getElementById("divAutoSave").innerHTML = "<b>Auto Save In " + nMinutes + " Minutes</b>";

}
}
function AutoSaveBeforeSubmit()

{

document.getElementById("divAutoSave").innerHTML = '<b>Saving data...Please wait.</b>';

return true;

}
function AutoSaveClearTimeOuts()

{

try

{

window.clearInterval(oInterval);

window.clearTimeout(oTimeOut);

}

catch (exception) { }
}
function AutoSaveSubmit()

{

try

{

AutoSaveClearTimeOuts();

AutoSaveBeforeSubmit();
/

Call the form submittal code in your main page.

/

SubmitFormToBeSaved();
}

catch (exception) {}

}
function AutoSaveRoundNumber(number,X)

{
var number2;

var TmpNum;
X=(!X ? 1:X);
number2 = Math.round(number*Math.pow(10,X))/Math.pow(10,X);

TmpNum = "" + number2;

var TmpArray = TmpNum.split(".");

if (TmpArray.length <2) { number2 = number2 + ".0"; }
return number2;

}
<!--Html text-->
<HTML>

<HEAD>

<script language=JavaScript src=/autosave.js></script>

<script language=JavaScript>

function SubmitFormToBeSaved()

{

alert('submitting form');

document.frmSubmit.submit();

}

</script>

</HEAD>
<BODY onload="AutoSaveInit(15000);">

<form name=frmSubmit id=frmSubmit method=post action=mypage.htm>

<div id=divAutoSave name=divAutoSave> </div>

<input type=text value='Time to save..' name=txtRobbe>

</form>

</BODY>

</HTML>