Jump to content

Create a submission counter


Recommended Posts

I have a datapage submission form which I need to make a counter based on an external parameter.

Virtual2 receives an external parameter (authorization field) on loading. This works fine.

Goods is a hidden field in the datapage. An updated value should be saved in this field on submission.

The script goes like below, but it doesn’t work. Actually I cant get goods to receive and store any value.

 

Please advise on solutions. 

 

<SCRIPT LANGUAGE="JavaScript">

Function calculate()

 {

   var number = parsefloat(document.getElementsByName('cbParamVirtual2')[0].value);

   var newnumber = number + 1;

   document.getElementById('InsertRecordgoods').value = newnumber;

 }

document.getElementById("caspioform").onsubmit= calculate;

</SCRIPT>

Link to comment
Share on other sites

Hi Rasmus,

Please set the "goods" field as a text field form element. Java script can't insert value into the hidden field. You may hide the goods field using the display:none attribute: http://howto.caspio.com/tech-tips-and-articles/common-customizations/how-to-hide-fields-in-datapages/

I've edited your code a little bit:

<SCRIPT LANGUAGE="JavaScript">

function calculate()

 {

   var number = parseFloat(document.getElementById("cbParamVirtual2").value);

   var newnumber = number +1;


   document.getElementById('InsertRecordgoods').value = newnumber;

 }

document.getElementById("caspioform").onsubmit= calculate;

</SCRIPT>

Hope it helps :)

Link to comment
Share on other sites

17 hours ago, Mathilda said:

 

Hi Mathilda

It works. Cheers.

One additional question. Is it possible to update and store the value in an 'authorization field' instead of the datafield 'goods'. The datapage can retrieve parameter values of authorization fields as users are logged in.

/ Rasmus

 

17 hours ago, Mathilda said:

 

Hi Rasmus,

Please set the "goods" field as a text field form element. Java script can't insert value into the hidden field. You may hide the goods field using the display:none attribute: http://howto.caspio.com/tech-tips-and-articles/common-customizations/how-to-hide-fields-in-datapages/

I've edited your code a little bit:


<SCRIPT LANGUAGE="JavaScript">

function calculate()

 {

   var number = parseFloat(document.getElementById("cbParamVirtual2").value);

   var newnumber = number +1;


   document.getElementById('InsertRecordgoods').value = newnumber;

 }

document.getElementById("caspioform").onsubmit= calculate;

</SCRIPT>

Hope it helps :)

 

Link to comment
Share on other sites

Hi Rasmus, I' m glad that it works for you :)

It's possible to increment value in the authentication field. You may use the following workflow:

* remove the script from the submission form;

* create a single-record update form, include one field (where you store value for increment), make field to be a text field form element, add an html block and insert the following script in the html block:
 

<SCRIPT LANGUAGE="JavaScript">

if(document.getElementById("caspioform")) {
  document.getElementById("caspioform").style.display = 'none';
}

function calculate()

 {

   var number = parseFloat(document.getElementById("EditRecordFieldname").value);

   var newnumber = number+1;


   document.getElementById('EditRecordFieldname').value = newnumber;

 }
  setTimeout('document.forms["caspioform"].submit(calculate())',1000); 

</SCRIPT>

Please insert your name of the field instead of Fieldname

* select "Go to the new page" and paste URL of the update form on the  Destination and Emails screen of the wizard of the submission form.

As a result, you enter data in the submission form, after submission you will be redirected to the auto-submission update form, and value in the authentication field will be incremented. Please note, you will not see submission of the second form, it will be hidden.

Please feel free to ask if something is unclear.

Link to comment
Share on other sites

On 8/9/2016 at 11:13 AM, Mathilda said:

Hi Rasmus, I' m glad that it works for you :)

It's possible to increment value in the authentication field. You may use the following workflow:

* remove the script from the submission form;

* create a single-record update form, include one field (where you store value for increment), make field to be a text field form element, add an html block and insert the following script in the html block:
 


<SCRIPT LANGUAGE="JavaScript">

if(document.getElementById("caspioform")) {
  document.getElementById("caspioform").style.display = 'none';
}

function calculate()

 {

   var number = parseFloat(document.getElementById("EditRecordFieldname").value);

   var newnumber = number+1;


   document.getElementById('EditRecordFieldname').value = newnumber;

 }
  setTimeout('document.forms["caspioform"].submit(calculate())',1000); 

</SCRIPT>

Please insert your name of the field instead of Fieldname

* select "Go to the new page" and paste URL of the update form on the  Destination and Emails screen of the wizard of the submission form.

As a result, you enter data in the submission form, after submission you will be redirected to the auto-submission update form, and value in the authentication field will be incremented. Please note, you will not see submission of the second form, it will be hidden.

Please feel free to ask if something is unclear.

Excellent, that worked too. However, maybe I should have explained what I try to solve, which is still outta reach. 

I have external users, and need to limit the number of active datarow(s) they can create. So I thought of using a counter with the authorization fields and then to limit what can be seen when the count exceeds a limit. But, seems not so easy... But maybe you have another suggestion ?

 

 

 

Link to comment
Share on other sites

5 minutes ago, Rasmus said:

Excellent, that worked too. However, maybe I should have explained what I try to solve, which is still outta reach. 

I have external users, and need to limit the number of active datarow(s) they can create. So I thought of using a counter with the authorization fields and then to limit what can be seen when the count exceeds a limit. But, seems not so easy... But maybe you have another suggestion ?

 

 

 

Hi Rasmus,

you may try using the following solution: 

http://howto.caspio.com/tech-tips-and-articles/advanced-customizations/how-to-limit-the-number-of-submissions/

It seems this is what you are looking for. 

 

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