Jump to content
  • 0
DesiLogi

Concatenate 2 Fields Into on on change of each field

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>

 

Share this post


Link to post
Share on other sites

1 answer 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>

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×