Skip to content

Author: admin@master

How can I loop through a JavaScript object array?

I am trying to loop through the following: I want to retrieve msgFrom and msgBody I’ve tried: But the console log prints [Object] Any ideas what im doing wrong? Answer It appears you may just have missed the “messages” property in the data, so the loop is likely iterating the root Object rat…

Stop form refreshing page on submit

How would I go about preventing the page from refreshing when pressing the send button without any data in the fields? The validation is setup working fine, all fields go red but then the page is immediately refreshed. My knowledge of JS is relatively basic. In particular I think the processForm() function at…

Passing string variable with spaces

In the following code: ‘set’ is a string variable which can have spaces in it. I’m noticing when it has spaces it’s not working correctly. How can I fix this? EDIT: For clarity, I’d like to keep the spaces intact. Answer You have to replace intermediate space (‘ ‘) wi…