sylvie Posted May 27, 2007 Report Share Posted May 27, 2007 There is a topic elsewhere in this forum called ? Combo ? Fields posted by casamurphy. As I am not sure if this topic is still active, I am posting my question here: I was very interested to read about creating a combo field in that post. I tried to recreate the script, but it is not working. I have two fields in my table: Firstname and Lastname. I am trying to combine these two fields into a third field (Firstname + Lastname). I understand that a script needs to be created, but I am not sure where this script should reside. Can you, please, help? Quote Link to comment Share on other sites More sharing options...
0 MediaServices Posted May 28, 2007 Report Share Posted May 28, 2007 Below is a script casamurphy posted to this forum on Nov 29, 2006 with a slight edit suggested by carol on Nov 30, 2006. This script ought to be modified to your specific needs. To use this solution, highlight to copy the code provided below and then paste it inside the HTML Footer section of your WebForm DataPage. <SCRIPT LANGUAGE=\"JavaScript\"> <!-- This function will take the values of three fields and append them one to another and store that string into a fourth field.--> function concatenate() { //(1) Retrieve the value of the field Name and store in a variable name. var name = document.forms[0].InsertRecordName.value; //(2) Retrieve the value of the field Prefix and store in a variable prefix. var prefix = document.forms[0].InsertRecordPrefix.value; //(3) Retrieve the value of the field URL and store in a variable url. var url = document.forms[0].InsertRecordURL.value; //(4) Retrieve the value of the field Suffix and store in a variable suffix. var suffix = document.forms[0].InsertRecordSuffix.value; //(5) Create the string and define a variable with that value. var link = name+prefix+url+suffix; //(6) Post the string to the targeted field. document.getElementById(\"InsertRecordLink\").value = link; } //(5) On submitting the webform, the function calculate is executed. document.forms[0].onsubmit=concatenate; </SCRIPT> Disclaimer: This is a user-supplied JavaScript solution and should be Used at your own risk! By using this or any other script you accept all responsibility and acknowledge that they are not a feature of Caspio's platforms and as such are provided \"as is\" without any warranties, support or guarantees. Quote Link to comment Share on other sites More sharing options...
0 sylvie Posted May 28, 2007 Author Report Share Posted May 28, 2007 Many, many thanks for your reply. Yes, I did copy the script into the footer, but it does not work. So I would like to find out what I am doing wrong. I have two fields Firstname and Lastname in my table called Students. I also added a field called Name to that table. I created a Web Form to capture submissions. I modified the script to include Firstname and Lastname to populate the third field called Name. I pasted this script inside the HTML footer: function concatenate() { //(1) Retrieve the value of the field Firstname and store in a variable firstname. var firstname = document.forms [0].InsertRecordFirstname.value; //(2) Retrieve the value of the field Lastname and store in a variable lastname. var lastname = document.forms[0].InsertRecordLastname.value; //(3) Create the string and define a variable with that value. var name = firstname+lastname; //(6) Post the string to the targeted field. document.getElementById(\"InsertRecordName\").name; } //(5) On submitting the webform, the function calculate is executed. document.forms[0].onsubmit=concatenate; I would be grateful for your help. Sylvie braxwell 1 Quote Link to comment Share on other sites More sharing options...
0 sylvie Posted May 28, 2007 Author Report Share Posted May 28, 2007 Just to let you know that the script worked. I made a mistake in the line for inserting the combined fields. Thanks. Quote Link to comment Share on other sites More sharing options...
0 diaster Posted August 23, 2009 Report Share Posted August 23, 2009 wghat was the mistake, i can't get it to work Quote Link to comment Share on other sites More sharing options...
0 MeghaJ Posted August 24, 2009 Report Share Posted August 24, 2009 Hi, I think the error is in the line: document.getElementById(\"InsertRecordName\").name; Instead of that, it should be document.getElementById(\"InsertRecordName\") = name; Regards, Megha Quote Link to comment Share on other sites More sharing options...
0 diaster Posted August 25, 2009 Report Share Posted August 25, 2009 This is what I have in the html footer and no results.... any help? function concatenate() { //(1) Retrieve the value of the field City and store in a variable city. var city = document.Forms [0].InsertRecordCity.value; //(2) Retrieve the value of the field Zip and store in a variable zip. var zip = document.Forms[0].InsertRecordZip.value; //(3) Create the string and define a variable with that value. var cityzip = zip+city; //(6) Post the string to the targeted field. document.getElementByid(\"InsertRecordName\") = cityzip; } //(5) On submitting the webform, the function calculate is executed. document.Forms[0].onsubmit=concatenate; except nothing happens LOL Quote Link to comment Share on other sites More sharing options...
0 diaster Posted August 25, 2009 Report Share Posted August 25, 2009 from what i just read javascript has to be in the header, body or called as an external script. perhaps someone can be clear on exactly how to write this, every variation i have tried does not work. I have search the web and can't find this simple answer. I want to combine a user entered field called Zip with a user entered field called City into a hidden field (or not) called cityzip. I will then use this field to search for places allowing the input for field cityzip as "contains" (either city or zip) Quote Link to comment Share on other sites More sharing options...
0 bahar_vm Posted August 25, 2009 Report Share Posted August 25, 2009 The error is on the line document.getElementByid(\"InsertRecordName\") = cityzip; Looking at the original code, it should be document.getElementById("InsertRecordName").value = cityzip; What is the hidden field that you try to assign the concatenated value into? Base on the line above, this fields should be called Name. Now if you have it with a different name you have to modify this line and replace Name in InsertRecordName with the field name you have. The Java Script could be either inserted in the DataPage footer block or an HTML block at the end of all field elements in "Field Configuration" wizard screen. Best, Bahar M. Quote Link to comment Share on other sites More sharing options...
0 diaster Posted August 25, 2009 Report Share Posted August 25, 2009 the name is Cityzip, i shall try what you just posted with changes Quote Link to comment Share on other sites More sharing options...
0 diaster Posted August 25, 2009 Report Share Posted August 25, 2009 this is exactly what i have and it still doesn't work function concatenate() { //(1) Retrieve the value of the field City and store in a variable city. var city = document.Forms [0].InsertRecordCity.value; //(2) Retrieve the value of the field Zip and store in a variable zip. var zip = document.Forms[0].InsertRecordZip.value; //(3) Create the string and define a variable with that value. var cityzip = city+" "+zip; //(6) Post the string to the targeted field. document.getElementById("InsertRecordCityzip").value = cityzip; } //(5) On submitting the webform, the function calculate is executed. document.Forms[0].onsubmit=concatenate; http://b3.caspio.com/folderlogout/ Quote Link to comment Share on other sites More sharing options...
0 diaster Posted August 25, 2009 Report Share Posted August 25, 2009 is there anything at all, any field i need to modify ie getelementbyId do i have to do something with the id field of the form? Quote Link to comment Share on other sites More sharing options...
0 anonymous3009 Posted August 26, 2009 Report Share Posted August 26, 2009 Hello, This is what I have on my DataPage and it works fine. Note that my City, Zip and ZipCity are all of type Text in the table. Also I am using ZipCity as hidden field on the DataPage. Upon submit, the ZipCity field gets populated with the concatenated field. Hope it works for you. -------------------------------------------------------------------- function concatenate() { var city = document.getElementById("InsertRecordCity").value; var zip= document.getElementById("InsertRecordZip").value; var cityzip = city+ " " +zip; //alert("Cityzip: " + cityzip ); document.getElementById('InsertRecordZipCity').value = cityzip; } document.forms[0].onsubmit=concatenate; ------------------------------------------------------------------- Regards, -SO Quote Link to comment Share on other sites More sharing options...
0 diaster Posted August 26, 2009 Report Share Posted August 26, 2009 i'll try it thanks Quote Link to comment Share on other sites More sharing options...
0 diaster Posted August 29, 2009 Report Share Posted August 29, 2009 Okay your scripts worked great! Thank you. I replaced your field with my fields and no problem. Now do you have a clue as to why it won't work in my 'search and modify" data page. all the data gets changed but the zipcity field gets blanked out. Its updating it with a blank value, weird. Quote Link to comment Share on other sites More sharing options...
0 anonymous3009 Posted August 31, 2009 Report Share Posted August 31, 2009 Hi, On the Search and Report(S/R) DataPage, the prefix to address the fields on the form is EditRecord. So the JS on a S/R would be: function concatenate() { var city = document.getElementById("EditRecordCity").value; var zip= document.getElementById("EditRecordZip").value; var cityzip = city+ " " +zip; //alert("Cityzip: " + cityzip ); document.getElementById('EditRecordZipCity').value = cityzip; } document.forms[0].onsubmit=concatenate; Best, -SO Quote Link to comment Share on other sites More sharing options...
0 diaster Posted September 10, 2009 Report Share Posted September 10, 2009 thanks I'll try it Quote Link to comment Share on other sites More sharing options...
0 diaster Posted September 15, 2009 Report Share Posted September 15, 2009 worked excellent!! thanks Quote Link to comment Share on other sites More sharing options...
0 cheonsa Posted March 17, 2019 Report Share Posted March 17, 2019 Hi all, Just to give you an update, Caspio released new features last year. One of these is the Calculated Value in the Submission Form. You don't need to insert custom script on your DataPage to concatenate two fields. The Calculated Value form element generates dynamic calculations that automatically update as users interact with your form. Please see screenshot below: You can get more information on this link: https://howto.caspio.com/datapages/datapage-components/calculated-values/ -kristina Quote Link to comment Share on other sites More sharing options...
0 NailDyanC Posted March 21, 2019 Report Share Posted March 21, 2019 Hi Just to add to the previous comment above, In the new release of Caspio version 17.0 , you can now add the Calculated Value form element to Update Forms and Details Pages to generate dynamic calculations as users interact with your forms. Previously, this feature was only available in Submission Forms. You may also check this link about calculated value: https://howto.caspio.com/datapages/datapage-components/calculated-values/ Also, you can Concantenate two fields in your Table using a Formula field. Quote Link to comment Share on other sites More sharing options...
0 RuisiHansamu Posted April 13, 2023 Report Share Posted April 13, 2023 There is a similar forum post that is related to this: Quote Link to comment Share on other sites More sharing options...
0 Kronos Posted April 13, 2023 Report Share Posted April 13, 2023 Hi, Just wanted to share this forum thread if you would like to display your results in a DataPage in one line: Quote Link to comment Share on other sites More sharing options...
Question
sylvie
There is a topic elsewhere in this forum called ? Combo ? Fields posted by casamurphy.
As I am not sure if this topic is still active, I am posting my question here:
I was very interested to read about creating a combo field in that post.
I tried to recreate the script, but it is not working.
I have two fields in my table: Firstname and Lastname. I am trying
to combine these two fields into a third field (Firstname + Lastname).
I understand that a script needs to be created, but I am not sure where this script should reside.
Can you, please, help?
Link to comment
Share on other sites
21 answers to this question
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.