This topic is locked

Add New Record Form Button Id - Js?

1/12/2013 9:28:41 PM
PHPRunner General questions
A
Athlon author

Hi bit lost with this .. I have an add page open - lots of code runs on teh events for this form but i want it to run (automatically) without user clicking the add record or save button.
I thought this would be simple but I have some mis-understandings in how this must be working. Can someone please advise?
function autoCertificate(){

// NOT IE browser

var evt = document.createEvent("MouseEvents");

evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);

var saveData = document.getElementById("saveButton1");

var canceled = !saveData.dispatchEvent(evt);

}
I am calling autoCertificate(); on the java on load events and expected the page to just save and redirect as i have specified in the events as soon as it loads.

All works as intended but i can not seem to get the button to click automatically using js.. No errors ..
What am i doing wrong - is the button ID something else?
Thanks,
Mike.