last day (15 days later) » 

6:45 PM
0
Q: How to access elements from a javascript array for an email sent with PHP/HTML

Michael Anthony LeberSo I am working on a webpage that generates a javascript array from the date element in html. That array itself works fine, and I am able to print it to the webpage by using a command like this: document.getElementById("demo").innerHTML = week[0]; to access the "week" array generated within...

 
Is this wha you are looking for ?
 
Well, I'm not sure. I went into that and used: "JSON.stringify(week);" in the javascript and: "$datesOfWeek = json_decode($_POST['jsondata']);" later on in the php, but whenever I try to print any of the array out, there's nothing.
 
I think you have made mistake with POST.Try to put your array in place of jsondata.
 
Alright, I tried that, but it still doesn't work. It sends the email and everything, but where that element should print there is nothing.
 
How did you use that to print ?
 
6:45 PM
Well I took the $datesOfWeek array and saved the first value into a php variable like this: "$dateMonday = $datesOfWeek[0];" Then in the html email I wrote "$dateMonday" into the message (this is all using PHP's mail function, so this particular portion was within a PHP variable called "$email_body").
I moved this to chat if that's okay.
 
Is it giving you some error ??
 
No
It lets me go through the whole form and send the email
 
Can you try like this :
 
but once the email is sent, in the location where I have the php variable "$dateMonday" placed, there's nothing there.
 
Ok 1 min
 
6:52 PM
HOLY YESSSSSSSSSSSSS
The other guy's solution worked!!!!!
Sorry lol
 
Haha !!
great ..
Enjoy coding !!
 

last day (15 days later) »