Jump to content

Js: Auto-Submit A Datapage


caspio

Recommended Posts

JavaScript Solution: Auto-Submit a DataPage
 
Feature Description:
This JavaScript solution shows how to auto-submit a DataPage. Caspio DataPage only submits to one table so if you need to perform submission to multiple tables you can use another DataPage and the following JavaScript to auto submit.

Implementation:
This solution can be used "as-is", without any changes if 

a. It is used in a Submission, Single Record Update, or Details DataPage and
b. The DataPage is the only one Caspio DataPage deployed on your web page.

c. The "progress_bar" image exists on your site: www.yoursite.com/images/progress_bar.gif. Or the URL should be adjusted to where your file is located.


To use this solution, copy the code below and paste inside the HTML Header section of the DataPage using the Caspio Bridge DataPage Wizard.
 

<div align="center" id="processing"> <p>Processing...</p> <img src="images/progress_bar.gif" alt="Progress Bar" width="200" height="15" /> </div>

 
Then insert an HTML Block, copy the code below and paste inside the HTML Block section:
 

<script type="text/javascript"> 
document.addEventListener('DataPageReady', function (event) {
           const error = document.querySelector('div[data-cb-name="HeaderErrorMsg"]');
           if(!error){
                if(document.getElementById("caspioform")) {
                document.getElementById("caspioform").style.display = 'none';
                setTimeout('document.forms["caspioform"].submit()',1000); } 
           }    
});
</script>

 
In  submission successful message area, click on Source button and paste the code below.

<style type="text/css">
#processing{
display:none;
}
</style>

 

Tested Browsers
This JavaScript solution was tested on the following platforms and Internet Browsers only.
# MS Windows - IE 10, Firefox 25.0.1, Chrome 31.0.1650.57, Safari 5.1.7


Disclaimer: Use these JavaScript solutions at your own risk! They are provided to assist you in the customization of your programs and while we believe they work properly, by using them you accept all responsibility about them and confirm that they are not a feature of Caspio's platforms and as such are provided "as is" without any warranties, support or guarantees. 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...