Jump to content
  • 0

Auto submit form intefering with other data pages


oliverk

Question

Hello

I'm using the script below in an html block to make a submission datapage autosubmit.

However, my webpage has two other static datapages on it, with the submit buttons hidden. When this autosubmit code runs, it submits one of the other datapages too. Is there a way to make it only submit the particular submission form that it's attached to, e.g. by specifying the app key?

If it's relevant, this submission box is in a modal that appears on top of a tabular datapage.

Thanks!

 

<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>

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hello @oliverk,

Please test this code in the HTML block. It refers to the specific DataPage ([@cbAppKey])

<script> 
document.addEventListener('DataPageReady', function (event) {
 if (event.detail.appKey != '[@cbAppKey]') { return }

     const error = document.querySelector('form[action*="[@cbAppKey]"] > div[data-cb-name="HeaderErrorMsg"]');
     const thisForm = document.querySelector('form[action*="[@cbAppKey]"]');
         if(!error){
             if(thisForm) {
                 thisForm.style.display = 'none';
                 setTimeout(thisForm.submit(),1000);
             }
         }
});
</script>

 

Link to comment
Share on other sites

  • 0
3 hours ago, CoopperBackpack said:

Hello @oliverk,

Please test this code in the HTML block. It refers to the specific DataPage ([@cbAppKey])

<script> 
document.addEventListener('DataPageReady', function (event) {
 if (event.detail.appKey != '[@cbAppKey]') { return }

     const error = document.querySelector('form[action*="[@cbAppKey]"] > div[data-cb-name="HeaderErrorMsg"]');
     const thisForm = document.querySelector('form[action*="[@cbAppKey]"]');
         if(!error){
             if(thisForm) {
                 thisForm.style.display = 'none';
                 setTimeout(thisForm.submit(),1000);
             }
         }
});
</script>

 

This is perfect! Many thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...