form autosave/submit code solved

sakyildiz

Member
Hi everyone. I tried to find a solution in order to save/apply changes in my form automatically in certain time intervals. Here's the solution I've found. I added a php plugin to my form and choosed the process script "After the end of the form (getEndContent)". The php custom code I used was as follows:
-------
echo "<script>\n";
echo "function applyclick() {\n";
echo "var x = document.getElementsByClassName(\"btn button\");\n";
echo "var i;\n";
echo "for (i = 0; i < x.length; i++) {\n";
echo " if (x.name == \"apply\") {\n";
echo " x.click();\n";
echo " }\n";
echo "}\n";
echo "}\n";
echo "setInterval(applyclick, 180000);</script>\n";
------
this creates a javascript which identifies the form's apply button and fires its click event every 30 seconds.
the following php code does not work
echo "<script>setInterval(function(){ var x = document.getElementsByName(\"apply\"); x[0].click; }, 3000);</script>\n";

I hope this helps someone.
 
something happens to my php code when i post it here. strange. i try posting the commented php code
/*
echo "<script>\n";
echo "function applyclick() {\n";
echo "var x = document.getElementsByClassName(\"btn button\");\n";
echo "var i;\n";
echo "for (i = 0; i < x.length; i++) {\n";
echo " if (x.name == \"apply\") {\n";
echo " x.click();\n";
echo " }\n";
echo "}\n";
echo "}\n";
echo "setInterval(applyclick, 30000);</script>\n";
*/
 
the code seems to turn into italic font after using variable i. so i post the whole code with using variable j instead of i.
-----

echo "<script>\n";
echo "function applyclick() {\n";
echo "var x = document.getElementsByClassName(\"btn button\");\n";
echo "var j;\n";
echo "for (j = 0; j < x.length; j++) {\n";
echo " if (x[j].name == \"apply\") {\n";
echo " x[j].click();\n";
echo " }\n";
echo "}\n";
echo "}\n";
echo "setInterval(applyclick, 30000);</script>\n";

------
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top