Expand my Community achievements bar.

Help with a JavaScript email submit button taking word null out if blank

Avatar

Level 2

     First of all I dont know much about java, but I wanted to create a submit button and I did alot of research.  I want a button that will email some pdf files I have created in LiveCycle.  So far everyting works but my code needs help.

     There are a few fields I want to be place in the body of the e-mail, but if left blank I dont want null to apear on the email subject or body.

Here is what I have so far *this is a work around, but it not very good.

strSubject

= "Account "+DropDownList1.rawValue+" For: " +last.rawValue +", " +first.rawValue +" " +mi.rawValue;

if

(mi.rawValue ==null || mi.rawValue =="")strSubject = "Account "+DropDownList1.rawValue+" For: " +last.rawValue +", " +first.rawValue;

     The 4 fields am working on are First name, last name, Mi and comments.  First and last are alwasy used, but if MI is not I dont want Null in there, with what I have above it works but its messy.  I wanted to do the same with Comments if its left blank I like for it to read "Comments: None" not null

On the If statement I just re did the whole deal with out the  mi.rawvalue but i now that is not right way... any help would be great.

Thanks

2 Replies

Avatar

Level 10

May be you can try like below..

var strDropDownListValue,strFirstName, strLastName, strMI

if(DropDownList1.rawValue == null || DropDownList1.rawValue == "")
       strDropDownListValue = "";
else
     strDropDownListValue = DropDownList1.rawValue;


if(first.rawValue == null || first.rawValue == "")

strFirstName = "";
else
     strFirstName = first.rawValue;

if(mi.rawValue == null || mi.rawValue == "")
     strMI = "";
else
     strMI = mi.rawValue;

if(last.rawValue == null || last.rawValue == "")
     strLastName = "";
else
     strLastName = last.rawValue;

strSubject = "Account "+ strDropDownListValue +" For: " + strLastName +", " + strFirstName +" " + strMI;

Thanks
Srini

Avatar

Level 2

That worked.  I mod it a bit, and got it to do what I needed it to do, thanks so much.  This site really kills the copy paste of coode

I have so many things I want to learn to do, but with time i guess

Thanks again