Here what we have done is, when the submit is called we first do some work ("onSubmit=setValue()") by using the onSubmit method. The onSubmit method will invoke setValue() function defined by us.
After that the action will take place and stringTokens.php will be called.
Step 3: Here we define the setValue method. The method will convert the array periviously defined in to a string and then set it to the hidden field.
<script language=javascript>
function setValue()
{
var arv = scriptAr.toString();
// This line converts js array to String document.test.arv.value=arv;
// This sets the string to the hidden form field. }
</script>
Step 4:In the php file the string will be split back into array.
Let us consider we get a value from a post action one,two,three
i.e: $ss = $_POST['arv'];
Now using the php method explode() we will convert the string in to a array object :
explode(separator,string);
Example : $tok = explode(',',$ss);
so we have got a string array. Now we print the array using print_r() method. This method prints the array in string format.
print_r($tok);
The result
Array ( [0] => one [1] => two [2] => three )