CroixRonaldCoppge Posted February 11, 2015 Report Share Posted February 11, 2015 I have two javascript functions, 1) to concatenate the first and last name and 2) to calculate age. Independently, they work, but when I place both in the footer of my datapage, the last function (age calculation) is the only one the works. Can someone tell me how to combine two functions in the footer of a datapage so they both work. Thanks, vtoykpar93 1 Quote Link to comment Share on other sites More sharing options...
iren Posted February 11, 2015 Report Share Posted February 11, 2015 Hello EYESINC, As far as I know 'Concatenate/Combine two fields into one field' and 'Perform a calculation on values entered in a WebForm' JavaScript solutions perform functions in a Submission Form. They both use the 'onsubmit' event, but only one function can be done after submit. I would recommend you to combine two functions in one: <SCRIPT LANGUAGE="JavaScript"> function calculate() { var position1 = document.getElementById("InsertRecordPosition1").value; var position2 = document.getElementById("InsertRecordPosition2").value; var allpositions = position1 + position2; document.getElementById("InsertRecordAllPositions").value = allpositions; var v_price = parseFloat(document.getElementById("InsertRecordPrice").value); var v_quantity = parseFloat(document.getElementById("InsertRecordQuantity").value); var v_total = (v_price * v_quantity); document.getElementById("InsertRecordTotal").value = Math.round(v_total); } document.getElementById("caspioform").onsubmit=calculate; </SCRIPT> Enter names of your fields instead of Position1, Position2, Price, Quantity. Hope it helps Quote Link to comment Share on other sites More sharing options...
CroixRonaldCoppge Posted February 18, 2015 Author Report Share Posted February 18, 2015 Hi, Iren: Thanks for taking the time to look at this for me. What you say makes sense; however, I followed your suggestion, and it doesn't work. Independently, they work. Can you look at the code below and see if you see what I'm doing wrong? Thanks <SCRIPT LANGUAGE="JavaScript"> function concatenate() { var Firstname = document.getElementById("EditRecordFirst").value; var Lastname = document.getElementById("EditRecordLast").value; var Final = Firstname +" "+ Lastname; document.getElementById("EditRecordFullname").value = Final; //get current date var stamp = new Date(); //get Birthday. change "InsertRecordBirthday" if the fieldname is different var insertDate = document.getElementById("EditRecordDOB").value; var birth = new Date(insertDate); //calculation difference = stamp - birth; age = Math.floor(difference / (1000 * 60 * 60 * 24 * 365.25)); //assign it to Age field document.getElementById("EditRecordAge").value = age; } document.getElementById("caspioform").onsubmit=concatenate; </SCRIPT> Quote Link to comment Share on other sites More sharing options...
Jan Posted February 23, 2015 Report Share Posted February 23, 2015 Hello EYESINC, Please make sure that all names are correct and the code is entered to the Footer element. Also you can change the last line to document.getElementById("caspioform").onsubmit=concatenate(); I hope, it helps. P.S. If the code still does not work, could you provide the URL of your page? 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.