I have a list of mobile networks and another one for the price, I want when user change select from first selection the other changing
<script>
$("#network").on("change", function() {
    $states = $("#states");
    $states.find("optgroup").hide().children().hide();
    $states.find("optgroup[label='" + this.value + "']").show().children().show();
    $states.find("optgroup[label='" + this.value + "'] option").eq(0).prop("selected", true);
});
</script>
<select name="network" id="network">
  <option value="Vodafone">فودافون </option>
  <option value="Etisalat">اتصالات </option>
  <option value="Orange">اورانج </option>
 </select></label>
  <label>الرقم
   <input type="number" style="width:90px" onkeypress="return event.charCode >= 48 && event.charCode <= 57" name="phone" placeholder="رقم المحمول"/> </label>
  
<select id="states">
    <optgroup label="Vodafone">
 <?php for ($x = 1; $x <= 200; $x++) {
     echo "<option value='" . $x . "'>" . $x . "</option>";
} 
?>
    </optgroup>
 <optgroup label="Etisalat">
        <option value="0.5">0.5</option>
        <option value="1">1</option>
        <option value="1.5">1.5</option>
        <option value="3">3</option>
        <option value="4">4</option>
  <?php for ($y = 5; $y <= 10; $y++) {
     echo "<option value='" . $y . "'>" . $y . "</option>";
} 
?>
<?php for ($ya = 15; $ya <=100; $ya=$ya+5) {
     echo "<option value='" . $ya . "'>" . $ya . "</option>";
} 
?>
 <option value="250">250</option>
    </optgroup>
  <optgroup label="Orange">
 <?php for ($z= 2; $z <= 20; $z++) {
     echo "<option value='" . $z . "'>" . $z . "</option>";
} 
?>
        <option value="25">25</option>
  <?php for ($za= 30; $za <= 100; $za=$za+10) {
     echo "<option value='" . $za . "'>" . $za . "</option>";
} 
?>
  <option value="200">200</option>
  <option value="500">500</option>
    </optgroup>
 </select>
I tried also make the JS as a function and use this as onclick on first select menu but nothing changed !