Tattoued Posted April 5, 2010 Share Posted April 5, 2010 FusionPro keeps giving me a syntax error and I'm so new at javascript I'm not seeing what is wrong! Help? if (Len(Field("First Name")) < 2) return Field("First Name"); Field("Last Name"); else return Field("First Name") If the first name is an initial, I want to return the first name (which would just be an intial with the last name. If there is a full first name, I want to return JUST the first name, no last name. Should the semicolons not be there or something? I just do NOT understand code. Update: Oh wait... I think I got it. I need to take out the semicolon and the second word "Field" so it's like this: if (Len(Field("First Name")) < 2) return Field("First Name")("Last Name"); else return Field("First Name") Nope. Sorry. Still need help. It's returning first and last name both regardless... *sigh* Oh geez... my bad. I forgot to replace the rule in the edit text field. It works fine! Thanks for reading! LOL Correction - It works except for one thing - I'm not getting a space between the first name initial and the last name. How do I get that? I added a space in with the space bar, but I assume I need something more? Link to comment Share on other sites More sharing options...
LesSjo Posted April 5, 2010 Share Posted April 5, 2010 if (Len(Field("First Name")) < 2) return Field("First Name")("Last Name"); else return Field("First Name") Try this: if (Len(Field("First Name")) < 2) { return Field("First Name") + " " + Field("Last Name"); } return Field("First Name"); Link to comment Share on other sites More sharing options...
Tattoued Posted April 5, 2010 Author Share Posted April 5, 2010 That's what I forgot was the plus sign. I had tried the " " but didn't use the plus sign. That did it! Thanks! Ok. So I have 3 fields of designations that go after a rep's name. There are 3 optional designations. If the second or third column in the csv file is empty, I don't want a comma at the end if the 3rd designation is empty. I don't have a clue where to even start on that rule. Link to comment Share on other sites More sharing options...
esmith Posted April 6, 2010 Share Posted April 6, 2010 Ok. So I have 3 fields of designations that go after a rep's name. There are 3 optional designations. If the second or third column in the csv file is empty, I don't want a comma at the end if the 3rd designation is empty. I don't have a clue where to even start on that rule. Building on Les' code: var result = ""; var desig = [Field("Designation1"), Field("Designation2"), Field("Designation3")]; if (Len(Field("First Name")) < 2) { result = Field("First Name") + " " + Field("Last Name"); } else result = Field("First Name"); for (i=0; i<desig.length; i++) { if (desig[i] != "") { result += ", " + desig[i]; } } return result; Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.