title: Notice: Undefined index: elegido in C:\xampp\htdocs\cars\index1.php on line
body: <p>i have a dynamic SELECT category menu, i get this error Notice: Undefined index: elegido in C:\xampp\htdocs\cars\index.php on line 30 , 40 &amp; 48 what makes the menu does not work properly. </p>
  
  <p><strong>WHAT IS CAUSING THIS ERROR?</strong></p>
  
  <p>LINES 30, 40 &amp; 48:</p>
  
  <pre><code> 30 if ($_POST["elegido"]==1) {
   40 if ($_POST["elegido"]==2) {
   48 if ($_POST["elegido"]==3) {
  </code></pre>
  
  <p><strong>HERE IS ALL THE CODE</strong></p>
  
  <pre><code>&lt;script ="javascript"&gt;
  $(document).ready(function(){
     $("#marca").change(function () {
             $("#marca option:selected").each(function () {
              elegido=$(this).val();
              $.post("modelos.php", { elegido: elegido }, function(data){
              $("#modelo").html(data);
              });            
          });
     })
  });
  &lt;/script&gt;
  &lt;p&gt;Marca: 
  &lt;select name="marca" id="marca"&gt;    
      &lt;option value="1"&gt;Renault&lt;/option&gt;
      &lt;option value="2"&gt;Seat&lt;/option&gt;
      &lt;option value="3"&gt;Peugeot&lt;/option&gt;    
  &lt;/select&gt;&lt;/p&gt;
  &lt;p&gt;Modelo:
  &lt;select name="modelo" id="modelo"&gt;    
      &lt;option value="1"&gt;4&lt;/option&gt;
      &lt;option value="2"&gt;5&lt;/option&gt;
      &lt;option value="3"&gt;7&lt;/option&gt;
      &lt;option value="4"&gt;21&lt;/option&gt;
      &lt;option value="5"&gt;Scennic&lt;/option&gt;
      &lt;option value="6"&gt;Traffic&lt;/option&gt;
  &lt;/select&gt;&lt;/p&gt;
  &lt;?php
  $options="";
  if ($_POST["elegido"]==1) {
      $options= '
      &lt;option value="1"&gt;4&lt;/option&gt;
      &lt;option value="2"&gt;5&lt;/option&gt;
      &lt;option value="3"&gt;7&lt;/option&gt;
      &lt;option value="4"&gt;21&lt;/option&gt;
      &lt;option value="5"&gt;Scennic&lt;/option&gt;
      &lt;option value="6"&gt;Traffic&lt;/option&gt;
      ';    
  }
  if ($_POST["elegido"]==2) {
      $options= '
      &lt;option value="1"&gt;Ibiza&lt;/option&gt;
      &lt;option value="2"&gt;Toledo&lt;/option&gt;
      &lt;option value="3"&gt;Cordoba&lt;/option&gt;
      &lt;option value="4"&gt;Arosa&lt;/option&gt;
      ';    
  }
  if ($_POST["elegido"]==3) {
      $options= '
      &lt;option value="1"&gt;106&lt;/option&gt;
      &lt;option value="2"&gt;206&lt;/option&gt;
      &lt;option value="3"&gt;306&lt;/option&gt;
      ';    
  }
  echo $options;    
  ?&gt;
  </code></pre>