•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 428,390 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,534 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 755 | Replies: 1
![]() |
•
•
Join Date: May 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Hi, I'm currently applying the autosave code i've got on the internet unfortunately I can't make it work. Below is the error encountered as well as the code being used.
Error Encountered:
Line: 4568
Char: 21
Error: Object Expected
Code being used:
Error Encountered:
Line: 4568
Char: 21
Error: Object Expected
Code being used:
<script type="text/javascript">
pollingInterval = 5000;
threadLock = false;
saveMessage = "saved"
function timeoutHandler(){
clearTimeout(SaveTimeout);
SaveTimeout = setTimeout("autosave()",pollingInterval);
}
function autosave(){
var changes = checkFormChanged(document.%formname);
if (changes && !threadLock) {
threadLock = true;
if ("%page" == "EP_APPR_BASE1")
$('input[@name=ICAction]').attr({value: 'EP_BTN_LINK_WRK_EP_STORE_PB'});
else
$('input[@name=ICAction]').attr({value: 'EP_BTN_LINK_WRK_EP_STORE_PB$19$'});
update_defaults(document.%formname);
var params = $('form[@name=%formname]').fastSerialize();
$.ajax({ type: "POST",
url: $('form[@name=%formname]').attr("action"),
data: $.param( params ),
dataType: "xml",
success:
function(msg, msg2)
{
$('input[@name=ICChanged]').attr({value: '0'});
var searchFor = "'ICStateNum' value='";
var stateNumStart = msg.responseText.indexOf(searchFor) + searchFor.length;
var stateNumEnd = msg.responseText.indexOf("'", stateNumStart);
var newState = msg.responseText.substr(stateNumStart, stateNumEnd - stateNumStart);
$('input[@name=ICStateNum]').attr({value: newState});
display_notification();
SaveTimeout = setTimeout ( "autosave()", pollingInterval );
var SearchFor = null;
var stateNumStart = null;
var stateNumEnd = null;
threadLock = false;
}
});
}
else
{
SaveTimeout = setTimeout ( "autosave()", pollingInterval);
};
};
function start_autosave(){
if ("%PAGE" == "EP_APPR_MAIN1" || "%PAGE" == "EP_APPR_BASE1")
if ($('input[@name=ICChanged]').val() != 0){
SaveTimeout = setTimeout ( "autosave()", 1);
}
else
{
SaveTimeout = setTimeout ( "autosave()", pollingInterval );
}
$('body').keypress(timeoutHandler);
submitAction_%Formname = function(form, name){
form = $('form')[0];
$('body').css({cursor: "wait"});
function submit_the_form()
{
form.ICAction.value=name;
form.ICXPos.value=getScrollX();
form.ICYPos.value=getScrollY();
processing_%Formname(1,3000);
form.ICResubmit.value=nResubmit;
form.submit();
nResubmit++;
}
function check_for_lock()
{
if (threadLock){
setTimeout("submitAction_%Formname('" + %formname + "','" + name + "')",250);
}
else{
submit_the_form();
}
}
check_for_lock();
};
};
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
};
if ("%page" == "EP_APPR_MAIN1" || "%page" == "EP_APPR_BASE1")
{
addLoadEvent(start_autosave);
};
</script> Last edited by ~s.o.s~ : May 28th, 2008 at 11:10 pm. Reason: Added code tags, learn to use them.
Server side code has no place in the Javascript code, you should take a look at the generated code to pinpoint your problem. Use tools like the Error Console of Firefox and Firebug to debug your code.
I don't accept change. I don't deserve to live.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Previous Thread: Any advice on how to build a simple javascript form with a text field?
- Next Thread: customize eperformance page



Linear Mode