Notice: Undefined index: elegido in C:\xampp\htdocs\cars\index1.php on line -


i have dynamic select category menu, error notice: undefined index: elegido in c:\xampp\htdocs\cars\index.php on line 30 , 40 & 48 makes menu not work properly.

what causing error?

lines 30, 40 & 48:

 30 if ($_post["elegido"]==1) {  40 if ($_post["elegido"]==2) {  48 if ($_post["elegido"]==3) { 

here code

<script ="javascript"> $(document).ready(function(){    $("#marca").change(function () {            $("#marca option:selected").each(function () {             elegido=$(this).val();             $.post("modelos.php", { elegido: elegido }, function(data){             $("#modelo").html(data);             });                     });    }) }); </script> <p>marca:  <select name="marca" id="marca">         <option value="1">renault</option>     <option value="2">seat</option>     <option value="3">peugeot</option>     </select></p> <p>modelo: <select name="modelo" id="modelo">         <option value="1">4</option>     <option value="2">5</option>     <option value="3">7</option>     <option value="4">21</option>     <option value="5">scennic</option>     <option value="6">traffic</option> </select></p> <?php $options=""; if ($_post["elegido"]==1) {     $options= '     <option value="1">4</option>     <option value="2">5</option>     <option value="3">7</option>     <option value="4">21</option>     <option value="5">scennic</option>     <option value="6">traffic</option>     ';     } if ($_post["elegido"]==2) {     $options= '     <option value="1">ibiza</option>     <option value="2">toledo</option>     <option value="3">cordoba</option>     <option value="4">arosa</option>     ';     } if ($_post["elegido"]==3) {     $options= '     <option value="1">106</option>     <option value="2">206</option>     <option value="3">306</option>     ';     } echo $options;     ?> 

try this

if (isset($_post["elegido"])) {  //your code  } 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -