Link to home
Start Free TrialLog in
Avatar of chockmilk
chockmilkFlag for Thailand

asked on

Using PHP to get Javascript Array

Hi i have javascript Array for and i would like to pass it to the next page which is coded in PHP

Problem is I tried methods found in this site but all seem out of luck

In HTML JAVASCRIPT PAGE

blendArray = (1,2,3,4,5,6,7,8);

function setValue(){
  document.test.arv.value = blendArray;
  alert (document.test.arv.value);
}

<form action="phpArrayTest.php" method=post name=test onSubmit=setValue()>
<input name=arv type=hidden>
<input type=submit>

In PHP i use

$getArray = $_POST['arv'];

and print out $getArray but nothing shown.
Avatar of Roonaan
Roonaan
Flag of Netherlands image

you could use:

document.forms['test'] .arv.value = blendArray.join(";");

And in php use:

$getArray = explode(';', $_POST['arv']);

-r-
SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yikes :)
Avatar of chockmilk

ASKER

thanks alot guy for helping me out