title: Form Inside li and inside Loop
body: <p>Method Get Not Working iam not reciving any value when i hit the button that is inside li</p>
  
  <pre><code>&lt;?php 
   for ($j = 0; $j &lt; sizeof($subcat); $j++) {
     if($subcat[$j][3]==$cat[$i][0]){
     ?&gt; 
     &lt;li&gt;
      &lt;form name="form_producto_menu" action="" method="GET"&gt;
         &lt;input class="btn-menu-prod" type="button"  value="&lt;?php echo $subcat[$j][1];?&gt;" onclick="test();"&gt;
         &lt;input type="hidden" name="categoria" value="&lt;?php echo $cat[$i][0]; ?&gt;"&gt;
         &lt;input type="hidden" name="subcategoria" value="&lt;?php echo $subcat[$j][0]; ?&gt;"&gt;
      &lt;/form&gt;
    &lt;/li&gt;
  &lt;?php 
      }
  }
  ?&gt;
  </code></pre>
  
  <p>Iam having trouble with form, if i put the form outside the loop it works fine but i need it inside the loop and inside the tag li becuase outside ill recive long repeating array,but if it is inside ill get just the button i hit</p>
  
  <p>This is what i want and not working :</p>
  
  <pre><code>&lt;?php 
  require_once ('db/consultas.php'); 
  $reg = new Consultas(); 
  $cat=$reg-&gt;SelectCategoria();
  $subcat=$reg-&gt;SelectSubCategoria();
  if (isset($_GET['categoria'])) {
  print_r($_GET); 
  }
  ?&gt;  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Productos&lt;/title&gt; 
  &lt;?php include 'head.php'; ?&gt;
  &lt;meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;?php include 'header.php' ?&gt;
  &lt;div class="col-lg-2 col-sm-3 " style="padding:0; margin:0;"&gt;
      &lt;div class="contenedor-menu" style="margin-top: 100px;"&gt;
          &lt;a href="#" class="btn-menu"&gt;Menu &lt;i class="fa fa-bars"&gt;&lt;/i&gt;&lt;/a&gt;
          &lt;ul class="menu-producto "&gt;
              &lt;li&gt;&lt;a href="#"&gt;&lt;i class="icono izquierda fa fa-home" aria-hidden="true"&gt;&lt;/i&gt;Inicio&lt;/a&gt;&lt;/li&gt; 
              &lt;?php
              for ($i = 0; $i &lt; sizeof($cat); $i++) {
                  ?&gt;
                  &lt;li&gt;&lt;a href='#'&gt;&lt;?php echo $cat[$i][1]; ?&gt;&lt;i class='icono derecha fa fa-chevron-down' aria-hidden='true'&gt;&lt;/i&gt;&lt;/a&gt;
                      &lt;ul&gt;
                          &lt;?php 
                          for ($j = 0; $j &lt; sizeof($subcat); $j++) {
                              if($subcat[$j][3]==$cat[$i][0]){
                                  ?&gt; 
                                  &lt;li&gt; 
                                      &lt;form name="form_producto_menu" action="" method="GET"&gt;
                                          &lt;input class="btn-menu-prod" type="button"  value="&lt;?php echo $subcat[$j][1];?&gt;" onclick="test();"&gt;
                                          &lt;input type="hidden" name="categoria" value="&lt;?php echo $cat[$i][0]; ?&gt;"&gt;
                                          &lt;input type="hidden" name="subcategoria" value="&lt;?php echo $subcat[$j][0]; ?&gt;"&gt;
                                      &lt;/form&gt;
                                  &lt;/li&gt; &lt;?php 
                              }
                          }
                          ?&gt;
                      &lt;/ul&gt;   
                  &lt;/li&gt; 
                  &lt;?php
              }
  
              ?&gt; 
          &lt;/ul&gt; 
      &lt;/div&gt;
  &lt;/div&gt; 
  &lt;div class="container-productos-main col-lg-10 col-sm-9"&gt;
      &lt;div class="container-productos "&gt;
          d
      &lt;/div&gt;
  &lt;/div&gt; 
  &lt;?php include 'footer.php'; ?&gt; 
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This works but not what i need :</p>
  
  <pre><code>&lt;?php 
  require_once ('db/consultas.php'); 
  $reg = new Consultas(); 
  $cat=$reg-&gt;SelectCategoria();
  $subcat=$reg-&gt;SelectSubCategoria();
  if (isset($_GET['categoria'])) {
  print_r($_GET); 
  }
  ?&gt;  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Productos&lt;/title&gt; 
  &lt;?php include 'head.php'; ?&gt;
  &lt;meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form name="form_producto_menu" action="" method="GET"&gt;
  
  &lt;?php include 'header.php' ?&gt;
  &lt;div class="col-lg-2 col-sm-3 " style="padding:0; margin:0;"&gt;
      &lt;div class="contenedor-menu" style="margin-top: 100px;"&gt;
          &lt;a href="#" class="btn-menu"&gt;Menu &lt;i class="fa fa-bars"&gt;&lt;/i&gt;&lt;/a&gt;
          &lt;ul class="menu-producto "&gt;
              &lt;li&gt;&lt;a href="#"&gt;&lt;i class="icono izquierda fa fa-home" aria-hidden="true"&gt;&lt;/i&gt;Inicio&lt;/a&gt;&lt;/li&gt; 
              &lt;?php
              for ($i = 0; $i &lt; sizeof($cat); $i++) {
                  ?&gt;
                  &lt;li&gt;&lt;a href='#'&gt;&lt;?php echo $cat[$i][1]; ?&gt;&lt;i class='icono derecha fa fa-chevron-down' aria-hidden='true'&gt;&lt;/i&gt;&lt;/a&gt;
                      &lt;ul&gt;
                          &lt;?php 
                          for ($j = 0; $j &lt; sizeof($subcat); $j++) {
                              if($subcat[$j][3]==$cat[$i][0]){
                                  ?&gt; 
                                  &lt;li&gt; 
  
                                          &lt;input class="btn-menu-prod" type="button"  value="&lt;?php echo $subcat[$j][1];?&gt;" onclick="test();"&gt;
                                          &lt;input type="hidden" name="categoria" value="&lt;?php echo $cat[$i][0]; ?&gt;"&gt;
                                          &lt;input type="hidden" name="subcategoria" value="&lt;?php echo $subcat[$j][0]; ?&gt;"&gt;
  
                                  &lt;/li&gt; &lt;?php 
                              }
                          }
                          ?&gt;
                      &lt;/ul&gt;   
                  &lt;/li&gt; 
                  &lt;?php
              }
  
              ?&gt; 
          &lt;/ul&gt; 
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/form&gt; 
  &lt;div class="container-productos-main col-lg-10 col-sm-9"&gt;
      &lt;div class="container-productos "&gt;
          d
      &lt;/div&gt;
  &lt;/div&gt; 
  &lt;?php include 'footer.php'; ?&gt; 
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and this is my JS:</p>
  
  <pre><code>function test()
  {
  var form = document.form_producto_menu;
  alert('hola');
  form.submit();
  }
  </code></pre>
  
  <p><strong>Edit:</strong> On both case i get the message from my JS, it is working fine but when form is inside the loop the submit doesnt work  but i still getting the message of my JS.
  when i hit the button i get Empty Value of the method "GET" </p>