Javascript not executing in right order

Avatar

Avatar
Validate 10
Level 2
Jodi1725
Level 2

Likes

6 likes

Total Posts

113 posts

Correct reply

2 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 1
View profile

Avatar
Validate 10
Level 2
Jodi1725
Level 2

Likes

6 likes

Total Posts

113 posts

Correct reply

2 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 1
View profile
Jodi1725
Level 2

09-06-2015

Hey my great javascript buddies!!!  Okay So I have the following script on a click event:

var oDoc = event.target

Initial.presence = "hidden"

Printinfo.presence = "visible"

oDoc.mailDoc ({

                         bUI:true,

                         cTo: Name.rawvalue

                         cSubject: Hello

                         });

Why when I click the button does the email send first and then the field hide and become visible.  I need them to hide/visible before the form is emailed. 

What is even more weird is that sometimes it works find and other times it doesn't.  And I can't for the life of me figured out what is wrong!

Any help is always extremely appreciated!

Jodi


View Entire Topic

Avatar

Avatar
Validate 10
Level 2
Jodi1725
Level 2

Likes

6 likes

Total Posts

113 posts

Correct reply

2 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 1
View profile

Avatar
Validate 10
Level 2
Jodi1725
Level 2

Likes

6 likes

Total Posts

113 posts

Correct reply

2 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 1
View profile
Jodi1725
Level 2

14-02-2018

This is my actual script. (the above was just an example for ease) even when adding semi colons It still emails first and then hides the fields.  I even added the emailme, thinking that it would have to go through those steps first to get to the email me, but still no luck .

if (errorcount == 0)

                {Main.Type.presence = "hidden";

{var tables = Main.GIKDetails.Donor.all;

for (j = 0; j < tables.length; j++)

{if (tables.item(j).NewAdd.rawValue == "0")

{tables.item(j).NewAdd.presence = "hidden"};

if (tables.item(j).ForeignAddress.rawValue == "0")

{tables.item(j).ForeignAddress.presence = "hidden"};

tables.item(j).Spacer6.presence = "hidden";

}};

                {var tables = Main.GIKDetails.Donor.all;

                    for (j = 0; j < tables.length; j++)

                        {var table = tables.item(j);

                         var fund = table.FundInfo.all;

                         for (i = 0; i < fund.length; i++)

                         {var row = fund.item(i)

               

                if (fund.item(i).NewFund.rawValue == "0")

                {fund.item(i).NewFund.presence = "hidden";

                 fund.item(i).NewFundContact.presence = "hidden";

                 fund.item(i).NewFundEmail.presence = "hidden";}

                

           

                fund.item(i).NonGift.presence = "hidden";

                   

                if (fund.item(i).Opportunity.Opportunity2.No.rawValue == "2")

                {fund.item(i).Opportunity.presence = "hidden"};

               

                fund.item(i).Tribute.TributeTxt.presence = "hidden";

                fund.item(i).Tribute.Tribute2.presence = "hidden";

                       

                fund.item(i).AddDesig.presence = "hidden";

                fund.item(i).Spacer3.presence = "hidden";

                fund.item(i).RemoveDesig.presence = "hidden";

                emailme = emailme + 1;

   

       

               

               

                };

                };

                };

};

{if (emailme == 1)

{var oDoc = event.target;

                    oDoc.mailDoc({

            bUI : true,

            cTo : "cashdesk@uif.uillinois.edu",

            cCc : "",

            cSubject : "Gift In Kind - Gift Transmittal",

            cMsg : "",

        })}}