05
Days
23
Hours
59
Minutes
59
Seconds


Merge two Fields in RSForm!Pro for Joomla! User Registration

When using RSForm!Pro for Joomla! user registration, you might want to combine the values of two separate fields, like first name (firstname) and last name (lastname) fields into the Joomla! user field Name. This approach uses a Hidden field and JavaScript to dynamically update the combined value.

This guide explains how to achieve this by using a hidden field and a JavaScript function.


Step 1. Create the First and Last Name fields

Add two textbox fields to your form and name them firstname and lastname.


Step 2. Create a Hidden Field

Add a Hidden field to your form and name it (e.g., Name). Map this hidden field to the Joomla! User Registration field Name in the integration settings.


Step 3. Add JavaScript to Combine Values

Navigate to Form Properties > CSS and JavaScript > JavaScript and insert the following code:

<script type="text/javascript">
function copyValue(){
document.getElementById('Name').value = document.getElementById('firstname').value + ' ' + document.getElementById('lastname').value;
}
</script>

Step 4. Set up the trigger

Edit your firstname and lastname fields, go to the Attributes tab and add the following snippet in the Additional Attributes area:

onchange="copyValue();"

Save your form and test it to ensure that the firstname and lastname fields are successfully combined into the Name field upon submission.

 

Make sure that the IDs (firstname, lastname, and Name) in the script match the actual field IDs in your form.

 

Was this article helpful?

Yes No
Sorry about that