Question: passing ejs array to javascript function


passing ejs array to javascript function

Answers 1
Added at 2016-12-25 12:12

How do I pass an ejs array in a javascript function?

function validate(array) {
var ok = false;

var emailva = document.getElementById("email").value;
var passva = document.getElementById("password").value;  

  return ok;


Im passing my ejs array named as items to it something like this

<form role="form" action="/index-loggedin" method="post" onsubmit=" return validate("<%= items %>")" >

Any help?

nr: #1 dodano: 2016-12-25 14:12

I assume your function is located on the server. And you want to pass it a array from a html page (written with EJS). The only way to send an array from an HTML Page to a server is as a string thanks to JSON format. Hence, I advice you to send your array as JSON.stringify(array)

Source Show
◀ Wstecz