Jump to content

adaptation on auto-submit


Recommended Posts

Hi all

I have a simple datapage that submits a record to a table. values come from external parameters and it auto submits. This is the code I have at the HTML block:

<script type="text/javascript">

  if(document.getElementById("caspioform"))
 {
   document.getElementById("caspioform").style.display = 'none';
   setTimeout('document.forms["caspioform"].submit()',1000);
 } 
</script>

That works fine.

What I want to do, if possible, is to add a a clause, if one of the receiving parameters is null, then do not submit the form (or cancel?).

Any ideas?

Thanks

Link to comment
Share on other sites

13 hours ago, zock1 said:

Hi all

I have a simple datapage that submits a record to a table. values come from external parameters and it auto submits. This is the code I have at the HTML block:

<script type="text/javascript">

  if(document.getElementById("caspioform"))
 {
   document.getElementById("caspioform").style.display = 'none';
   setTimeout('document.forms["caspioform"].submit()',1000);
 } 
</script>

That works fine.

What I want to do, if possible, is to add a a clause, if one of the receiving parameters is null, then do not submit the form (or cancel?).

Any ideas?

Thanks

Hi,

Do you receive parameters in fields? You may check field length and execute auto submission only when lengths is >0. You may also add more conditions and check more than 1 field.

<script type="text/javascript">

var check=document.getElementById("InsertRecordField_name").value;
if (check.length>0){
  document.getElementById("caspioform").style.display = 'none';
  setTimeout('document.forms["caspioform"].submit()',1000); 
}

</script>

You need you use InsertRecordField_name if you use submission form. In case of using update or details datapage the syntax will be EditRecordField_name

Hope that helps

Link to comment
Share on other sites

Thanks Mathilda

I do receive the parameters in fields. I had to change the element from display only to text field. It does work when there is data coming from the parameter (check.length>0 is true), but if it's empty the datapage shows and sits there until I submit. Why is not cancelling?

Link to comment
Share on other sites

On 4/9/2017 at 10:05 PM, zock1 said:

Thanks Mathilda

I do receive the parameters in fields. I had to change the element from display only to text field. It does work when there is data coming from the parameter (check.length>0 is true), but if it's empty the datapage shows and sits there until I submit. Why is not cancelling?

If the value is blank, the form will not be submitted. According to your first description it was the expected behavior :)

What do you mean "not cancelling"? Redirect to another webpage?

Link to comment
Share on other sites

ok, a bit more information is needed.

There is a submission datapage (dpA) that inserts and maintains records from a table. I need also that a record is added into another table every time a new record is added on dpA. So this other datapage (dpB) receives values from parameters from dpA, inserts the record and returns control to dpA. I wanted to "hide" dpB, the user does not need to see it, and even more important, does not have to press "submit" again (already done at dpA). That's why I explored the autosubmit. So all works well this way.

The added functionality I wanted was to not add the related record in dpB when one of the passed parameter is empty. With the changes suggested, when the parameter is empty (else in check.length > 0), dpB becomes visible and I have to press the submit to return to dpA. which is not the behaviour I want. So I was expecting to have to add some code in the else part to cancel that form and return back to dpA:

while dpB hidden,

if parameter is empty then submit, else cancel,

return to DPA

Another option would be to trap the empty parameter in dpA before passing control to dpB, but I use the destination on the last part of the wizard and not sure how to put a condition there.

Hope that's a bit more clearer ...

Thanks in advance

 

Link to comment
Share on other sites

19 hours ago, zock1 said:

ok, a bit more information is needed.

There is a submission datapage (dpA) that inserts and maintains records from a table. I need also that a record is added into another table every time a new record is added on dpA. So this other datapage (dpB) receives values from parameters from dpA, inserts the record and returns control to dpA. I wanted to "hide" dpB, the user does not need to see it, and even more important, does not have to press "submit" again (already done at dpA). That's why I explored the autosubmit. So all works well this way.

The added functionality I wanted was to not add the related record in dpB when one of the passed parameter is empty. With the changes suggested, when the parameter is empty (else in check.length > 0), dpB becomes visible and I have to press the submit to return to dpA. which is not the behaviour I want. So I was expecting to have to add some code in the else part to cancel that form and return back to dpA:

while dpB hidden,

if parameter is empty then submit, else cancel,

return to DPA

Another option would be to trap the empty parameter in dpA before passing control to dpB, but I use the destination on the last part of the wizard and not sure how to put a condition there.

Hope that's a bit more clearer ...

Thanks in advance

 

Yes, your workflow is more clear now. I updated script with additional condition:

<script type="text/javascript">
window.onload=function myfunc(){
var check=document.getElementById("InsertRecordYour_field").value;

if (check.length>0){
  document.getElementById("caspioform").style.display = 'none';
  setTimeout('document.forms["caspioform"].submit()',1000); 
}
else {

window.location.href = "specify_your_url";
}
}
</script>

 

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
Reply to this topic...

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