Click here to Skip to main content
15,888,461 members
Home / Discussions / JavaScript
   

JavaScript

 
QuestionHow can I swap only body element between HTML pages? Pin
lino_7630-Aug-16 8:08
lino_7630-Aug-16 8:08 
AnswerRe: How can I swap only body element between HTML pages? Pin
Richard Deeming30-Aug-16 8:34
mveRichard Deeming30-Aug-16 8:34 
AnswerRe: How can I swap only body element between HTML pages? Pin
Nathan Minier31-Aug-16 1:55
professionalNathan Minier31-Aug-16 1:55 
QuestionCollect text and images from image pdf using JS or AngularJS Pin
Member 1270857628-Aug-16 22:47
Member 1270857628-Aug-16 22:47 
AnswerRe: Collect text and images from image pdf using JS or AngularJS Pin
Richard MacCutchan28-Aug-16 23:00
mveRichard MacCutchan28-Aug-16 23:00 
GeneralRe: Collect text and images from image pdf using JS or AngularJS Pin
Member 1270857629-Aug-16 0:18
Member 1270857629-Aug-16 0:18 
QuestionJavascript reverse help Pin
313help23-Aug-16 3:29
313help23-Aug-16 3:29 
AnswerRe: Javascript reverse help Pin
Richard Deeming23-Aug-16 4:35
mveRichard Deeming23-Aug-16 4:35 
Try walking through your code in your head:
  1. Take the name, 'FIRST LAST', and split it on every space ⇒ ['FIRST', 'LAST']
  2. Take the first element from the result, and store it ⇒ 'FIRST';
  3. Split the stored element on every space (NB: There aren't any!)['FIRST']
  4. Combine the second element of the one-element array with the first element ⇒ 'undefined,FIRST'


Now it should be obvious that you need to remove steps 2 and 3:
JavaScript
%{var parts = '${Case Name}'.split(' '); parts[1] + ', ' + parts[0]} 

However, you'll still get undefined if the entered name doesn't contain a space. If that could be the case, then you'll need the ternary operator:
JavaScript
%{var parts = '${Case Name}'.split(' '); parts.length == 2 ? parts[1] + ', ' + parts[0] : parts[0]} 


Adding a space after the comma is as simple as ... adding a space after the comma! Smile | :)



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: Javascript reverse help Pin
313help23-Aug-16 4:59
313help23-Aug-16 4:59 
Questionangular http post doesnt work on IIS Pin
Member 1103130422-Aug-16 19:34
Member 1103130422-Aug-16 19:34 
AnswerRe: angular http post doesnt work on IIS Pin
Richard Deeming23-Aug-16 1:43
mveRichard Deeming23-Aug-16 1:43 
GeneralRe: angular http post doesnt work on IIS Pin
Member 1103130423-Aug-16 19:28
Member 1103130423-Aug-16 19:28 
GeneralRe: angular http post doesnt work on IIS Pin
Richard Deeming24-Aug-16 1:47
mveRichard Deeming24-Aug-16 1:47 
GeneralRe: angular http post doesnt work on IIS Pin
Member 1103130424-Aug-16 2:34
Member 1103130424-Aug-16 2:34 
AnswerRe: angular http post doesnt work on IIS Pin
2374130-Aug-16 8:18
2374130-Aug-16 8:18 
QuestionJavascript chalange Pin
Asith Raj22-Aug-16 19:28
Asith Raj22-Aug-16 19:28 
QuestionRe: Javascript chalange Pin
Harpreet05Kaur26-Sep-16 1:52
Harpreet05Kaur26-Sep-16 1:52 
QuestionAnswer Pin
Member 1269199818-Aug-16 6:28
Member 1269199818-Aug-16 6:28 
AnswerQuestion Pin
Richard Deeming18-Aug-16 7:27
mveRichard Deeming18-Aug-16 7:27 
Questionjavacript alert message Pin
classy_dog17-Aug-16 8:22
classy_dog17-Aug-16 8:22 
AnswerRe: javacript alert message Pin
Richard MacCutchan18-Aug-16 2:30
mveRichard MacCutchan18-Aug-16 2:30 
AnswerRe: javacript alert message Pin
Karthik_Mahalingam20-Aug-16 18:16
professionalKarthik_Mahalingam20-Aug-16 18:16 
AnswerRe: javacript alert message Pin
Harpreet05Kaur26-Sep-16 1:54
Harpreet05Kaur26-Sep-16 1:54 
QuestionOnmouseover javascript 'JavaScript runtime error: 'LabelHover' is undefined' Pin
Bootzilla3317-Aug-16 7:27
Bootzilla3317-Aug-16 7:27 
AnswerRe: Onmouseover javascript 'JavaScript runtime error: 'LabelHover' is undefined' Pin
Karthik_Mahalingam20-Aug-16 18:21
professionalKarthik_Mahalingam20-Aug-16 18:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.