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 & 48 what makes the menu does not work properly.
WHAT IS CAUSING THIS ERROR?
LINES 30, 40 & 48:
30 if ($_POST["elegido"]==1) {
40 if ($_POST["elegido"]==2) {
48 if ($_POST["elegido"]==3) {
HERE IS ALL THE 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;
?>