leadma Posted March 12, 2014 Report Share Posted March 12, 2014 I found this script in the "help function". To be used in a "submission form". It says that I can replace INSERTRECORD With EDITRECORD if a want to to use the script in a details page of a Search an Report Datapage. I have a problem With that. Is there something more I have to do? <script Language="JavaScript"> function concatenate() { var position1 = document.getElementById("InsertRecordPosition1").value var position2 = document.getElementById("InsertRecordPosition2").value var allpositions = position1 + position2; document.getElementById("InsertRecordAllPositions").value=allpositions; } document.getElementById("caspioform").onsubmit=concatenate; </SCRIPT> Hermantak 1 Quote Link to comment Share on other sites More sharing options...
Jan Posted March 13, 2014 Report Share Posted March 13, 2014 Hello Leadma, In the script, semicolons after some lines are absent. You can try the code like: <script language="JavaScript"> function concatenate() { var position1 = document.getElementById("InsertRecordPosition1").value; var position2 = document.getElementById("InsertRecordPosition2").value; var allpositions = position1 + position2; document.getElementById("InsertRecordAllPositions").value=allpositions; } document.getElementById("caspioform").onsubmit=concatenate; </SCRIPT> Quote Link to comment Share on other sites More sharing options...
MayMusic Posted March 14, 2014 Report Share Posted March 14, 2014 Java Script is also case sensitive just so you know Quote Link to comment Share on other sites More sharing options...
tclemendor Posted July 29, 2014 Report Share Posted July 29, 2014 The solution here feels like the answer I am looking for, but I need a little help to implement. I have a first name field and a last name field on my submission form. I would like to create a new value for "full name" by concatenating the two. This needs to happen without necessarily "passing" the parameters since this is collected on the last page the user will interact with. I'm not really a JS person. I just know what I've learned implementing things here and there on Caspio. So my question is... If my First name field is FName, my last name field is LName and I want to create UserName, how specifically would I alter the code mentioned in this post? Do I use Position1? Substitute it? Use "caspioform"? Substitute it with a data page name? Sorry the question is so basic, but that's where I am. Thank you for any help. Quote Link to comment Share on other sites More sharing options...
Jan Posted July 29, 2014 Report Share Posted July 29, 2014 Hello tclemendor, If you work with a Submission form, you can copy the script and change only names like: InsertRecordPosition1 -> InsertRecordFName InsertRecordPosition2 -> InsertRecordLName InsertRecordAllPositions -> InsertRecordUserName There is JS Guide, maybe it can help. Quote Link to comment Share on other sites More sharing options...
tclemendor Posted July 30, 2014 Report Share Posted July 30, 2014 I found the answer on how to concatenate first and last name. Now I just need to know how to insert a space between the two... Thanks, T Quote Link to comment Share on other sites More sharing options...
tclemendor Posted July 30, 2014 Report Share Posted July 30, 2014 Jan, Does that mean that I can't add a third position and make give it a default value of a space (" ")? I modified the script as below... <script language="JavaScript"> function concatenate(){var position1 = document.getElementById("InsertRecordFname").value;var position2 = document.getElementById("InsertRecordSpace").value; var position3 = document.getElementById("InsertRecordLName").value;var allpositions = position1 + position2 + position3;document.getElementById("InsertRecordAllPositions").value=allpositions;}document.getElementById("caspioform").onsubmit=concatenate;</SCRIPT> I made the field "Space" hidden field with a default value on load of " ". But that value does not save. When go back there is no space in the field. Workarounds? t Quote Link to comment Share on other sites More sharing options...
tclemendor Posted July 30, 2014 Report Share Posted July 30, 2014 Never mind... I got it to work by adding +" "+ in the line var allpositions = position1 + " "+ position2; and removing the Space field. t Quote Link to comment Share on other sites More sharing options...
michaeltx Posted June 13, 2015 Report Share Posted June 13, 2015 I hope that someone can help. I am trying to implement this script in my datapage, but it will not work. I copied the following code into the footer of my datapage: <SCRIPT LANGUAGE="JavaScript">function concatenate(){var position1 = document.getElementById("InsertRecordPosition1").value;var position2 = document.getElementById("InsertRecordPosition2").value;var allpositions = position1 + position2;document.getElementById("InsertRecordAllPositions").value = allpositions;}document.getElementById("caspioform").onsubmit=concatenate;</SCRIPT> The following fields are in my table: position1 position2 allpositions When I complete my form it will not combine position1 and position2 as it is supposed too. I am testing the page deployed on my server. I also tried testing it not deployed and neither way will work. In my datapage I have included the field "allpositions" as a hidden field. What am I doing wrong? Please help. Thanks Quote Link to comment Share on other sites More sharing options...
Xiang Posted June 13, 2015 Report Share Posted June 13, 2015 Good evening, Michael! How are you doing? I'm learning the JavaScript now, so, I think, capital letters are a problem. Names of your fields don't contain them, but the code does. This code should work: <SCRIPT LANGUAGE="JavaScript">function concatenate(){var position1 = document.getElementById("InsertRecordPosition1").value;var position2 = document.getElementById("InsertRecordPosition2").value;var allpositions = position1 + position2;document.getElementById("InsertRecordAllPositions").value = allpositions;}document.getElementById("caspioform").onsubmit=concatenate;</SCRIPT> I'll be grateful, if you tell me if the code works. Have a nice day! Quote Link to comment Share on other sites More sharing options...
ychaudhry Posted August 9, 2015 Report Share Posted August 9, 2015 I am trying to use Concatenate on a Details page with no luck. I have changed "InsertRecord" to "Edit Record", but still not not working. Below is the code. <SCRIPT LANGUAGE="JavaScript"> function concatenate() { var position1 = document.getElementById("EditRecordDate").value; var position2 = document.getElementById("EditRecordCheck_Number").value; var position3 = document.getElementById("EditRecordLocation").value; var allpositions = position1 + position2 + position3; document.getElementById("EditRecordLookupID").value = allpositions; } document.getElementById("caspioform").onsubmit=concatenate; </SCRIPT> Any suggestions will be appreciated. Thank you Quote Link to comment Share on other sites More sharing options...
Jan Posted September 3, 2015 Report Share Posted September 3, 2015 Hi ychaudhry, Welcome to Caspio forum! The code looks like good. Could you please provide the URL to your DataPage to see the problem? Quote Link to comment Share on other sites More sharing options...
ychaudhry Posted September 4, 2015 Report Share Posted September 4, 2015 Thanks Jan. I was able to figure out the issue. I had a uneditable field as part of the concatenate. had to change from "EditRecordDate" to [@feild:Date] Quote Link to comment Share on other sites More sharing options...
alexm72 Posted August 26, 2017 Report Share Posted August 26, 2017 HI I am not a java script person but I thought Id add my 2cents If you want to combine 2 fields in to one, you can do it without Java script (sort of). In my app a user has to select a gym they go to via a drop down of preselected data in field1. If they select other in field 1 it is disabled, and they enter a gym in field 1. These 2 fields will be passed to my page 2 sign up form in a hidden field that will receive both (but one will be blank because it is disabled) To use your situation: First take the 2 fields and pass them to a single record update page on page 2 for example; when you submit the form where it says destination after submission, select go to a new page (page2) - Page 2 will have the single record update that will receive the 2 parameters into 1 field pass .../mywebsite.com?Full_Name=[@field:First_Name] [@field:Last_Name] to page 2 (space between the 2 fields) On Page 2, Make Full Name hidden and set to receive External Field; in this case [@field:Full_Name] Now the second page will receive the first and last name as 1 item! You would still have to submit page 2 and you could hide this (using Java) and then set page 2 to go to the page that page 1 was supposed to go to. Hope this helps Quote Link to comment Share on other sites More sharing options...
Kurumi Posted June 20, 2019 Report Share Posted June 20, 2019 Just an update. You can now use the Calculated Value in Update Forms and Details Page. You can see it here: https://howto.caspio.com/release-notes/caspio-bridge-17-0/ This allows you to generate calculations which you can use to concatenate your fields without using JS. I hope it helps! 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.