problem sending mail with javascript
Oct 02, 2013
hi i just try to send mail by javascript, but i can´t to achieve it!
i have 6 textbox defines with each variables, (Question1, Answer1 ...)
then, i set up the send button with the trygger "Execute Javascript" putting there:
var player = GetPlayer();
var Q1 = player.GetVar("Question1");
var A1 = player.GetVar("Answer1");
var email="teacher@domain.com";
var name="Juan Carlos";
var subject = "Ejercicio enviado por alumno UN2.3 INGLES";
var body_start = "Dear Teacher,\n" + name + " has sent you his/her answers:\n";
var body_end = "Please discuss this commitment with " + name + "\n";
var mailto_link = 'mailto:' +email+'?subject='+subject+'&body='+encodeURIComponent(body_start + Q1 + A1 + body_end);
win = window.open(mailto_link, 'emailWin');
but when i publish the html5 project i don´t get it to work fine!
My mail form is on a new layer (with 6 fields and the send mail button):
May be i didn't write the js right! what do you think? can you give me a hand on that (or some video tutorial)?
regards
juanma
12 Replies
Hi Juanma:
This is a very simple question, but one many people overlook.
Are the global Variables Question1 and Answer1 created?
Also does your Send Mail button have the JavaScript trigger alone, or do you have other triggers on the button?
Best Regards,
Dennis Hall
hi Dennis, i have the JavaScript trigger alone in my Send Mail button.
i`ve created the two variables too! how can i proceed now?
regards
juanma
Hi Juanma:
I have both the Flash and HTML5 correctly working the same in FireFox and I.E.
My only comment would be to inser spaces between your Question1 and Anser1 output in the email formating.
Maybe you were missing the Q1 and A1 Vars. Not sure.
I have attached my story for you to compare to yours.
If this helps, please mark this as solved so others may find it for their solutions as well.
Best Regards,
Dennis Hall
Hi Juanma! JavaScript is out of my realm of expertise, but I'm glad that you are getting some assistance from Dennis here
Thanks Dennis!
Hi Denis, I was trolling for some Java script help and found your very helpful post. It works great... until I try to use it in my story: then it suddenly stops working. I'm no java programmer, but I can copy and paste with the best of them. I imported my story into yours, and it worked at first. But when I tried to adjust it to fit my purpose, then it suddenly stops calling the email client... and even though I retain the original from you in a seperate scene, it also inexplicably stops working...
I also thought that maybe I could just use HTML, which is easier for me to parse. Is there a way you can pull a variable into a mailto: ? You can see I tried but failed.
Happy for anyone to offer up some suggestions.
Thanks
Stanton
For the above post, use this attachment instead. I discovered that I had not updated my variables... not that correcting this error helped :-(
Cheers,
Stanton
I am viewing this posting almost a year later - but I want to thank you Stanton for your javascript in "SDLC for TSA final Test.story". I was able to modify it to fit my needs and now it works in all the browsers and devices we tested. Thanks again! Another Chrome browser difficulty solved!!!!
Thanks for sharing Chere, glad to hear that
Hi Dennis,
I have been attempting to get this to work for a week now, I fell upon your template while I was researching for a solution. In every thread I have found the template is in HTML format, are you able to provide me with the storyline file type? Thanks so much for sharing!!!!
Hey Michelle - Sounds like you may be having an issue with the download as it is a .story file attached. I'll reattach for you here.
Hi Leslie!
That one worked! So weird, I could see it had a storyline file extension, but when I went download it pulled as an HTML. Thanks so much for your help and replying so quickly!!!!
No problem Michelle :)
This discussion is closed. You can start a new discussion or contact Articulate Support.