Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

separate value

Avatar

Level 2

I have a dropdown box that has names listed last name , first name (Doe, John).  What I'm wanting to do is reverse the order of the names (John Doe) in a text box.  Is this a possibility to do something like this and if how is it done?  Thanks in advance.

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

You can use the JavaScript split method to create an array from the selected drop down value and then assign the items in the array to the respective name field.

// form1.page1.name::exit - (JavaScript, client)

if (!(this.isNull)) {

  var nameStr = this.rawValue;

  var nameArray = nameStr.split(",");

  form1.page1.firstName.rawValue = nameArray[1];

  form1.page1.lastName.rawValue = nameArray[0];

}

Steve

View solution in original post

3 Replies

Avatar

Correct answer by
Former Community Member

You can use the JavaScript split method to create an array from the selected drop down value and then assign the items in the array to the respective name field.

// form1.page1.name::exit - (JavaScript, client)

if (!(this.isNull)) {

  var nameStr = this.rawValue;

  var nameArray = nameStr.split(",");

  form1.page1.firstName.rawValue = nameArray[1];

  form1.page1.lastName.rawValue = nameArray[0];

}

Steve

Avatar

Level 2

Steve

Thanks again for your assistance, it worked great!

Avatar

Former Community Member

Hi Steve,

I would like to do a similar thing but instead of the drop down list, it is a text box and its value populates from a web service that created in workbench. e.g. full name in the text box ppopulate: "Smith, John T" then I'd like to convert it to "John T Smith"

Can you please advise.

Thanks in advance,

Han Dao

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----