How to pass array and show in another program [closed]

0

I have the following variable in JS : m_aluno[w_cont_i][w_cont_j][w_cont_k] ; Where in every posição her (0,0,0) I added a value! My doubt is:  "How to get this variable and move to the next program the same way it is and then add it again to JS so you can display it in the same way."

Code:

    <?php
//Monta o array
    print("<SCRIPT language=javascript>  
             w_ii = \"$w_cole\"; //valor suposto = 2
             m_aluno = new Array(w_ii); // numero de colegios

             w_jj = \"$w_sala\"; //valor suposto = 2
             for (w_i=0; w_i<=w_ii; w_i++) 
             { m_aluno[w_i] = new Array(w_jj);} // Numero de salas   


             w_kk =  \"$w_mate\"; //valor suposto = 2          
             for (w_i=0; w_i<w_ii; w_i++) 
                 {
                 for (w_j=0; w_j<w_jj; w_j++)
                     { m_aluno[w_i][w_j] = new Array(w_kk); } // numero de materias
                 }  
             w_cont_i = 0;    w_cont_j = 0;    w_cont_k = 0;
             w_cont_cole = \"$w_cole\";    w_cont_sala = \"$w_sala\";    w_cont_mate = \"$w_mate\";
           </SCRIPT>");
    ?>

Inserts values according to what the user types:     

function f_inse_alun()
{
w_form ="frm_cad_op1";
w_nome = document.forms[w_form].tx_nome.value;


  m_aluno[w_cont_i][w_cont_j][w_cont_k] = w_nome;

  if (w_cont_k <= (w_cont_mate-1)) // se materia for menor entra
     { 
       w_cont_k++;  // incrementa a materia
     }

  if ((w_cont_j <= (w_cont_sala-1)) && (w_cont_k > (w_cont_mate-1))) // se sala for menor entra
     {                
     w_cont_k=0;
     w_cont_j++;  // incrementa a sala
     }              

  if ((w_cont_i <= (w_cont_cole-1)) && (w_cont_j > (w_cont_sala-1))) // se colegio for menor entra  
      {
      w_cont_j=0; // sala
      w_cont_k=0; // materia
      w_cont_i++; // incrementa o colegio
      }

 if (w_cont_i > (w_cont_cole-1))
     {
     alert("//chamar o programa para mostrar;");
     parent.location.replace("../Array/arrays_2.php?m_aluno="+m_aluno);     
     //vai ser usado para mostrar no outro form
      }

return true;
}   
</script>

Verifying that in the last if I put a call to pass array , but failed!

    
asked by anonymous 13.11.2014 / 12:41

1 answer

1

You can use local javascript storage, or use post via ajax. There are several ways to work with this array. Another option would be to transform the array into JSON and pass it via GET through the URL using the JSON.stringify(seuarray) function as seen here .

Then to return the array form on the other side, by javascript itself it is possible to do it using this tutorial .

I will leave some tutorials already answered on the other methods of transposing arrays:

13.11.2014 / 13:08