• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Combine first and last name fields?

Combine first and last name fields? 12 years 8 months ago #14283

  • CalenxarJake
  • CalenxarJake's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
  • Thank you received: 4
Using RS User Registration along with RSForm!Pro and Jomsocial.

I think I need to use a hidden field along with some code. I've got a field to input First Name and a field for Last Name. The issue I have is that Joomla's Core Registration uses Full Name as the default variable.

I don't know php or sql all that well. Some guidance would be appreciated! If you can give a small breakdown as well it would help me get started on figuring out how php works. Thanks in advance!
The administrator has disabled public write access.

Re: Combine first and last name fields? 12 years 8 months ago #14478

  • lacym
  • lacym's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
Did you ever receive a response on this or figure this out? I'm trying to do the same thing.
The administrator has disabled public write access.

Re: Combine first and last name fields? 12 years 7 months ago #14573

  • CalenxarJake
  • CalenxarJake's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
  • Thank you received: 4
I figured it out on my own, but I can't access it at the moment. I'll get it up later tonight.
The administrator has disabled public write access.

Re: Combine first and last name fields? 12 years 7 months ago #14578

  • CalenxarJake
  • CalenxarJake's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
  • Thank you received: 4
Got it, it's pretty easy.

In my form, there's a field named "First Name" and one called "Last Name"

Make a hidden field (mine is named "Joomla Name") and in Default Value I put
"{First Name:body} {Last Name:body}" (include the quotation marks)

Hope it helped you!
The administrator has disabled public write access.

This message has been removed by user's request. 12 years 7 months ago #14753

  • 63f691c2fa0e87d7519da8989de5042e@RSJOOMLA_DELETED
  • 63f691c2fa0e87d7519da8989de5042e@RSJOOMLA_DELETED's Avatar
This message has been removed by user's request.
The administrator has disabled public write access.

Re: Combine first and last name fields? 12 years 6 months ago #15139

  • CalenxarJake
  • CalenxarJake's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
  • Thank you received: 4
So that last part was completely wrong, I wasn't looking in the correct location.

Head to the form's Properties>CSS and Javascript and drop this in the Javascript section.
<script type="text/javascript">
function calculatename()
 {
document.getElementById('Joomla Name').value = document.getElementById('First Name').value + ' ' + document.getElementById('Last Name').value;
return true; 
} 
</script>

This formula will take the value of First Name, add a space, then add the value of Last Name. The result will be assigned to Joomla Name, which can then be mapped to wherever.

The next step is calling the function. In the Additional Attributes section for the Submit button, drop in this code...
onclick="calculatename();"

This will tell the function to run.

Lastly, make sure to make First Name and Last Name required.
The administrator has disabled public write access.
The following user(s) said Thank You: adam3, 9d8137fc0b0118d3308edeb7da179925, hayabusa hitsugaya, hacker007

Re: Combine first and last name fields? 10 years 8 months ago #24299

  • adam3
  • adam3's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 10
Just a quick note to say thanks for this. Works a treat with RSForm! Pro 2.5-3.0 Rev47.

Make a hidden field (mine is named "Joomla Name") and in Default Value I put
"{First Name:body} {Last Name:body}" (include the quotation marks)


For the benefit of others, you don't actually need to put in the Default Value - that's what the Javascript does for you ;)

Adam.
The administrator has disabled public write access.

Re: Combine first and last name fields? 9 years 10 months ago #27817

  • vieng
  • vieng's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
That didn't work in my form.
What did work was:
Make a hidden field (e.g. Namecomplete) and in the default value put
{First Name:value} {Second Name:value} {Last Name:value}

In the e-mail use {Namecomplete:value} to get the combination of the 3.
If one field has no value, it isn't shown, not even the extra space!
You can use your own field names of course. :)

Rob
The administrator has disabled public write access.

Re: Combine first and last name fields? 9 years 10 months ago #27819

  • vieng
  • vieng's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
Hmm, in form 1 it works, in form 2 it doesn't...
The administrator has disabled public write access.

Re: Combine first and last name fields? 9 years 10 months ago #27824

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
You can achieve this with PHP Scripts as well . With a hidden field created, insert the following in the PHP Scripts on form process:
$_POST['form']['hidden_fieldname'] = $_POST['form']['name_field'] . " " . $_POST['form']['last_name_field'];
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.

Re: Combine first and last name fields? 9 years 10 months ago #27942

  • djbunn
  • djbunn's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
Can you use this process to create an email address on the form:

For example

First Name: Jo
Last Name : Bloggs

A field is automatically populated with an email address using the data from the above two fields

for example

This e-mail address is being protected from spambots. You need JavaScript enabled to view it

Thanks

Damian
The administrator has disabled public write access.

Re: Combine first and last name fields? 9 years 10 months ago #27943

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
yes, it can be achieved but the syntax will be a little different, you will have to remove the space and add the domain. e.g.
$_POST['form']['hidden_field'] = $_POST['form']['field1'] . $_POST['form']['field2'] ."@something.com";
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.

Re: Combine first and last name fields? 9 years 9 months ago #28047

  • vieng
  • vieng's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
Thanks, I will try that.
Has the 'form' to be adjusted as well? I guess I have to put here the complete name of the form?
I use a field: Middle name, if that's empty reform handles that well and doesn't put an extra space in the name. A " " is a programmed space. Is there anything to do about that (sorry only little PHP knowledge)?
The administrator has disabled public write access.

Combine first and last name fields? 9 years 3 months ago #29912

  • elegeia
  • elegeia's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
Weird thing...

I managed to make this work only using the js solution. That means that if the person trying to sign up has javascript turned off he won't be able to sign up!

I managed to get the first name and last name fields populated if the user is logged in using php. I also took the joomla name, split it in two or three and managed to get first name middle name and last name...

However I can't use the damn hidden field with the {'First Name':value} or {First Name:value} or any other place holders!
by the way, I can use the {global:username} placeholders just fine. I use that to retrieve the user's username and emails. So the anchor placeholders work, just the {field name:value} doesn't!!!

Am I missing something?
The administrator has disabled public write access.

Combine first and last name fields? 9 years 3 months ago #29919

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
I will provide further information on this.

The javascript solution :
<script type="text/javascript">
function calculatename()
 {
document.getElementById('JoomlaName').value = document.getElementById('FirstName').value + ' ' + document.getElementById('LastName').value;
return true; 
} 
</script>

with the trigger on the submit button (Additional Attributes):
onclick="calculatename();"

This will populate a field (can be hidden) which has the id "JoomlaName' with the concatenated values of the 'FirstName' and 'LastName' fields upon clicking the submit button.

The PHP solution:
$_POST['form']['JoomlaName'] = $_POST['form']['FirstName'] . $_POST['form']['LastName'];

This script will have to be inserted in Scripts called on Form Process. While this does not populate the actual field, the following variable
$_POST['form']['JoomlaName']
will take the value of the other 2 concatenated values before it gets saved in the database.

If your "JoomlaName" field is required for validation, you should assign it a default value (this value is used to pass the initial validation, it will be overwritten after clicking the Submit Button).

--

As for the placeholders, please keep in mind that you will need to use the correct placeholder. The correct syntax should be {field_name:value}, please note that there is no space in an ID. You can click the toggle quick add and a complete list of placeholders will be displayed.

Let me know if it works or if there is something you didn't understand.
My help is not official customer support. To receive your support, submit a ticket by clicking here
Last Edit: 9 years 3 months ago by cosmin.cristea.
The administrator has disabled public write access.
The following user(s) said Thank You: hayabusa hitsugaya

Combine first and last name fields? 8 years 9 months ago #31806

  • info3946
  • info3946's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 18
  • Thank you received: 1
This is what worked for me

Step 1
Create hidden field called "fullname"
Set Default Value as "Jane Doe"

Step 2
Add Cosmins script to php script - Script called on form process
if(empty($invalid)){
$_POST['form']['fullname'] = $_POST['form']['firstname'].' '.$_POST['form']['lastname'];
}

Step 3
Set your joomla registration plugin to
Name = fullname
Last Edit: 8 years 9 months ago by info3946.
The administrator has disabled public write access.
The following user(s) said Thank You: info4683

Combine first and last name fields? 4 years 5 months ago #39642

I solved it as follow:

In this way the "name" field is automatically filled in when the user enters the Firstname and Lastname. The user can optionally change the "name" field to his own made-up name.

1. Textbox Field named "Firstname"
2. Textbox Field named "Lastname"
3. Textbox Field named "name" (I have the following description on that field: "The name that wil show on the website.")

Put in the "Additional Attributes" from fields 1. "Firstname" and field 2." Lastname":
onblur="changeVal()";

In the Form's "CSS and Javascript" tab put the code:
<script type="text/javascript">
function changeVal()
 {
document.getElementById('name').value = document.getElementById('Firstname').value + ' ' + document.getElementById('Lastname').value;
} 
</script>
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!