andym Posted February 19, 2013 Share Posted February 19, 2013 We have a company where users have various long, multiple part business units. If the person has more than one business unit, it is separated by a "/". I am new to JavaScript, but managed to piece this together: TypeSplit = Field("Title 2").split("/"); return TypeSplit[0] +'/'+ "\n" +TypeSplit[1]+ "\n"; It does what I want, unless the person only has one business unit, in which case it returns with '/ <br> undefined' What can I write to make one unit not have the '/' and 'undefined' ? I want it to return " " I appreciate any input you can offer. -Andy Quote Link to comment Share on other sites More sharing options...
step Posted February 19, 2013 Share Posted February 19, 2013 Try using a replace function instead of a split. This way it will search the string for a "/" and replace it with a break tag. I used a regex so that it can handle multiple instances of "/" thus inserted a break tag per "/". return Field("Title 2").replace(/\//g,"<br>"); Quote Link to comment Share on other sites More sharing options...
andym Posted February 19, 2013 Author Share Posted February 19, 2013 Thank you Ste. It works for the user with one Business Unit, but when they have two, I get this: Automotive Aftermarket Midwest <br> Midwest Automotive Service Solutions It isn't treating the <br> as a break... Quote Link to comment Share on other sites More sharing options...
dreimer Posted February 19, 2013 Share Posted February 19, 2013 Do you have the box checked for the treat returned strings as tagged text? Quote Link to comment Share on other sites More sharing options...
andym Posted February 19, 2013 Author Share Posted February 19, 2013 (edited) THAT DID IT!! THANK YOU BOTH! All I had to do was add the "/" in front of the "<BR>" to get the final product we needed: return Field("Title 2").replace(/\//g,"/<br>"); I appreciate the quick responses. Andy Edited February 19, 2013 by andym Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.