GraceFam2016 Posted November 3, 2015 Report Share Posted November 3, 2015 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? Quote Link to comment Share on other sites More sharing options...
Aurora Posted November 4, 2015 Report Share Posted November 4, 2015 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 Quote Link to comment Share on other sites More sharing options...
kmlgd Posted April 25, 2016 Report Share Posted April 25, 2016 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 Quote Link to comment Share on other sites More sharing options...
MayMusic Posted April 26, 2016 Report Share Posted April 26, 2016 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. Quote Link to comment Share on other sites More sharing options...
kmlgd Posted April 30, 2016 Report Share Posted April 30, 2016 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 Quote Link to comment Share on other sites More sharing options...
MayMusic Posted May 2, 2016 Report Share Posted May 2, 2016 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; Quote Link to comment Share on other sites More sharing options...
Olfa Posted May 17, 2016 Report Share Posted May 17, 2016 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 helpOlfa Quote Link to comment Share on other sites More sharing options...
Kurumi Posted October 22, 2018 Report Share Posted October 22, 2018 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! Quote Link to comment Share on other sites More sharing options...
JolliBeng Posted December 23, 2018 Report Share Posted December 23, 2018 Hi! Just to add more information about the Calculated Values: As of Dec. 6, 2016, Calculated Values can use other Calculated Values in Submission Forms. You may want to check Caspio Bridge 16.0 to know more details about the current release. -JolliBeng Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.