Javascript php fixes

0

I have the following page ... my problem is that I want to select a state and that below it shows me the state card that I select .. the problem is that those cards come in fixes and I have caused many errors .. some idea for When I click on it, show me the card I want? thank you very much

this is the arrangement of the status shown

$stads= array("MIRANDA", "AMAZONA", "ANZOATEGUI"," APURE"," ARAGUA"," BARINAS"," CARABOBO"," COJEDES"," DELTA AMACURO"," DISTRITO CAPITAL"," CARACAS"," FALCON"," LARA"," MERIDA"," MONAGAS"," NUEVA ESPARTA"," PORTUGUESA","SUCRE","TACHIRA"," TRUJILLO"," VARGAS"," YARACUY"," ZULIA ");
$arrlength= count($stads);
echo "
<div class='col-md-3'>
    <div class='form-group'>
        <label for='cuadro1'>Estados:</label>
            <select class='form-control' id='cuadro1' name='taskOption'>
";

echo "<option value='' id='cuadro2'></option>";
for ($x=0; $x < $arrlength ; $x++) { 
 if ($stads [$x]!=null ) {
    $cc= $stads[$x];

echo "<option value='$cc' id='cuadro2'>$cc</option>";
    }
}
echo " </select>
    </div>
</div>";



//y  este es el arreglo que se muestran en los card .. 



for ($i=1; $i < $arrayres ; $i++) { 
 if ($arrayPal [$i]!=null ) {
    $ah = explode(';',$arrayPal[$i]);
    //print_r($ah[1]); 
    $cd = $ah[1];
    $ef = $ah[2];
 $as = $ah[18];
    $a3= ucfirst(strtolower($ah[25]));
    if ($cd=='LEGAL_PERSON') {
      /*
   echo "
        <div class='col-sm-4'> 
  <div class='w3-card-4'>
    <header class='w3-container w3-light-grey' style=' width: 350px; overflow:hidden; text-overflow:ellipsis; height:60px;' >
      <h5 style='color:#0D47A1;' > $ah[2]</h5>
    </header>
    <br>
    <div class='w3-container'>
      <img src='' alt='Avatar' class='w3-left w3-circle w3-margin-right' style='width:60px; height:70px;'>
    <div class'b' style='  height: 71px; overflow:hidden; text-overflow:ellipsis; color:#424242; ' >  $a3</div>
    </div>
  </div>
  <br>
</div>
";

    */
    }   else{
$a4= strtoupper($ah[3]);

/*
        echo "
        <div class='col-sm-4'> 
  <div class='w3-card-4'>
    <header class='w3-container w3-light-grey' style='width: 350px; overflow:hidden; text-overflow:ellipsis; height:60px;'>
      <h5 style='color:#0D47A1;'> $a4 </h5>
    </header>
    <br>
    <div class='w3-container'>
      <img src='' alt='Avatar' class='w3-left w3-circle w3-margin-right' style='width:60px;'>
    <div class'b' style='height: 71px; overflow:hidden; text-overflow:ellipsis;color:#424242;' >  
    $a3</div>
    </div>
  </div>
  <br>
</div>
"; */
    
asked by Daniel Martinez 23.07.2018 в 15:49
source

1 answer

0

Bro, the ideal is that you use a data base in which you relate the states, but if you need to do so, here is an example you can use with JS:

 $(document).ready(function(){

  $("#cuadro1").change(function(){


    if ( $("#cuadro1").val() == "MIRANDA") {

       // aqui puedes hacer lo que deseas si el la opcion

    }else if ( $("#cuadro1").val() == "ANZOATEGUI") {

        // aqui puedes hacer lo que deseas si el la opcion

    }else if ( $("#cuadro1").val() == "APURE") {

        // aqui puedes hacer lo que deseas si el la opcion

    }else if ( $("#cuadro1").val() == "ARAGUA") {

        // aqui puedes hacer lo que deseas si el la opcion

    }else if ( $("#cuadro1").val() == "BARINAS") {

        // aqui puedes hacer lo que deseas si el la opcion

    } // y asi sucesivamente hasta que valides todos... 

  });

});

Or maybe you can also implement the [switch case], I hope it serves you and you mark it as valid, luck my Bro By: JJ

    
answered by 23.07.2018 / 16:25
source