I have a javascript array and want to send it to the php via form input hidden field. What i'm doing is here:
html:
<form method="post" action="a.php" onSubmit="fun();">
<input type="hidden" name="hiddenF" value="">
</form>
and in javascript:
function fun()
{
var jArray = [ "One", "Two", "Three"];
document.getElementsByName("hiddenF").value = JSON.stringify(jArray);
}
and finally in php that i need an array doing like below but i don't get anything on page.
$arr=json_decode($_POST['hiddenF']);
print_r($arr);
echo $_POST['hiddenF'];
? – skafandri Jul 10 at 8:55