Jump to content

Calculations In Onscreen From


Recommended Posts

Hi,

   I have a form that has several fields that need to be calculated and show the user, the final total in the Amount Due field.  Example.  The user will choose the number of adults attending, if the person types in 2, the 2 should be multiplied by $50.00 which will show $100.00 to the user in the Amount Due field.  Is this possible to do with a submit form?

Link to comment
Share on other sites

Hello GraceFam2016. 

 

Here is a script that might help you: 

<SCRIPT LANGUAGE="JavaScript">

function concatenate()
{
var field = parseFloat(document.getElementById("InsertRecordYour_Field1").value);

var field2=document.getElementById("InsertRecordYour_Field2") ;

field2.value = field+field;

}


document.getElementById("caspioform").onchange=concatenate;

</SCRIPT>

I take value of the First Field, double it and make it showed in the Second Field. 

 

I hope this helps. 

 

 

Aurora ;)

Link to comment
Share on other sites

  • 5 months later...

I am trying to do very similar, but cant get it to work.

 

<SCRIPT LANGUAGE="JavaScript">

 function calculate()
 {
   var entrada = parseFloat(document.getElementById("InsertRecordHora_Entrada").value);
   var salida  = parseFloat(document.getElementById("InsertRecordHora_Salida").value);
   var total  = (salida - entrada);
   document.getElementById("InsertRecordHoras_Trabajadas").value = Math.round(total);
 }

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

</SCRIPT>

 

 

as I saw in other caspio indications. but doesnt work.

dont know what i am doing wrong.

 

the fields where the script should be getting the data from are

Hora_Entrada

Hora_Salida

 

and the field where I guess the result should appear at:

Horas_Trabajadas

Link to comment
Share on other sites

Is it a submission page? Where do you have your code? It has to be in the Footer and make sure to click on Source.

 

Also if the page is deployed try the direct link and see if that works. if not then give me the URL to the page.

Hi, thank you for the answer.

 

Yes it is a submision form.

Code I think in the Footer but will check again, maybe html block, I tried several things so i am not sure where I put it last time XD, hit the source button for sure.

 

Will try again and will get back to you.

 

Actually maybe forget about it, cuase i am going to need at least 4 pages, register, submision form, update, and display. Iwas trying to do it on the free account. Limit is 3 so I will not be able to finish my app anyway :(

Link to comment
Share on other sites

Do you have more than one DataPage deployed on the same web page by any chance ? If yes then you will need to give the DataPage you have the calculation on an ID. To do so, add Header/Footer. Disable text editor for both

 

Header:

<div id="mypage">

Footer:

</div>

 

Then change this line of the code: document.getElementById("caspioform").onsubmit=calculate;

 

to

 

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

Link to comment
Share on other sites

  • 2 weeks later...

Hi Kmlgd,

 

i think the problem is that the variable are not taking the values of your fields, you have to replace " the getElementById " by "getElementsByName" like bellow

<SCRIPT LANGUAGE="JavaScript">

 function calculate()
 {
   var entrada = parseFloat(document.getElementsByName("InsertRecordHora_Entrada")[0].value);
   var salida  = parseFloat(document.getElementsByName("InsertRecordHora_Salida")[0].value);
   var total  = (salida - entrada);
   document.getElementsByName("InsertRecordHoras_Trabajadas")[0].value = Math.round(total);
 }

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

</SCRIPT>

hope this would help

Olfa

Link to comment
Share on other sites

  • 2 years later...

Hi @GraceFam2016,

As of July 12, 2018, Caspio introduced new features which you can find here: https://howto.caspio.com/release-notes/caspio-bridge-13-0/

This release includes a new feature, Calculated Values in Submission Forms.  This allows you to generate calculations which you can use for your Amount Due field. On your calculated value, you can use the formula like this: [Name of your field where the user will type the number of adults] *  $50.00

 Check these videos for more information:

 

 

I hope this helps!

Link to comment
Share on other sites

  • 2 months later...

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