Jump to content
  • 0

Concatenate 2 Fields Into on on change of each field


DesiLogi

Question

Hello,

I've got a submission form with 2 fields that I need to concatenate into one field (ideally with a space between the values as it's a 'first name' and 'last name' value that need to be put into a 'full name' field. Again, I'm trying to do this on Change for First or Last name so Full_Name autofills as the user enters values. 

The code I'm using below doesn't work so I must be missing something. If someone can look at the syntax that'd be awesome. 

<SCRIPT LANGUAGE="JavaScript">

$("#InsertRecordFirst_Name, #InsertRecordLast_Name").change(function(){

var v_first = document.getElementById("InsertRecordFirst_Name").value;
var v_last = document.getElementById("InsertRecordLast_Name").value;

var v_fullname = v_first + v_last;

document.getElementById("InsertRecordFull_Name").value = v_fullname;

});

</SCRIPT>

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

I got it worked out. Here it is if anyone needs it.

<script>
$("#InsertRecordFirst_Name").change(function(){

var v_first = document.getElementById("InsertRecordFirst_Name").value;
var v_last = document.getElementById("InsertRecordLast_Name").value;

var v_full = v_first  + " " + v_last;

document.getElementById("InsertRecordFull_Name").value = v_full;

});

</script>

 

Link to comment
Share on other sites

  • 0

Hi @DesiLogi,

 

Last year, Caspio released a new feature called Calculated Value. This form Element is available in the Submission form. The Calculated Value form element generates dynamic calculations that automatically update as users interact with your form. 

To concatenate two fields, you don't need to use a custom script anymore. 

image.png.448c9f9a8821482bc90749302bd7df2f.png

 

Please refer to this link for more information: https://howto.caspio.com/datapages/datapage-components/calculated-values/

 

Hope this helps.

 

-kristina

Link to comment
Share on other sites

  • 0

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.

image.thumb.png.8043245e2c79b911baf6b71e29a797df.png

 

I hope that helps.

 

Link to comment
Share on other sites

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
Answer this question...

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