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
Views
Replies
Total Likes
i am still looking for an answer to this question if anyone has any ideas
Thanks!
Jodi
Views
Replies
Total Likes
Hi Jodi,
Some lines of your code are missing semicolons at the end.
Views
Replies
Total Likes
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 : "",
})}}
Views
Replies
Total Likes
Hi Jodi,
I have sometimes also had problems with things not executing in the order i like, so I go about it another way.
What you can try is this:
Because your original button is conditionally sending the email if the emailme variable = 1, you might need to add another condition that will end the code.
For example
if (emailme == 1)
{
newButton.ExecEvent("click"); //this will click the new hidden send email button programmatically
}
if (emailme == 0)
{
end; //end the execution of the code
}
Views
Replies
Total Likes
Still doesnt work. the only reason for the condition was so that maybe it would prevent the email from happening before hiding the other fields.
So I removed the conditions and put the newButton.ExecEvent("click') at the end of all the hiding conditions and it still fires before it hides the fields.
Views
Replies
Total Likes
What about if you just had a separate email button that shows after the 'processing' has been done for hiding the fields? Just means the user will have to click another button, but at least it will do the email when you want.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies