Change 2nd Drop down values if 1st Drop down values get changed?

Good Evening... I am new to Laravel and coding and trying to Change 2nd Drop down values if 1st Drop down values get changed. getting the data from database

blade File

<div class="col-sm-6">
      <div class="form-group">
        <label>Select Animal Type <span class="validate">*</span> :</label>
          <select class="form-control" name="selectanimaltype" id="selectanimaltype" 
            <option value="buffalo">Buffalo</option>
            <option value="buffaloowcalf">Buffalo Calf</option>
            <option value="cow">Cow</option>
            <option value="cowcalf">Cow Calf</option>

    <div class="col-sm-6">
      <label>Select Animal ID <span class="validate">*</span> :</label>
      <select class="form-control" name="selectanimalid" id="selectanimalid" required="required">
      <option value=''>Select Animal ID</option>    
        @foreach($getbuffaloid as $item)
          <option value="{{ $item->buffaloID }}" data-type="{{ $item->type }}">{{ $item->buffaloID }}</option>

Getting Animal ID data from database which should be shown in 2nd Drop down menu. Controller File.

$getbuffaloid     = Buffalodata::get();
$getbuffalocalfid = BuffaloCalfdata::get();
$getcowid         = Cowdata::get();
$getcowcalfid     = CowCalfdata::get();

I tried to use onchange(), and getting alert for each selection..

function getanimalid(element)
var animal      = element.options[element.selectedIndex].text;

                if (animal == "Buffalo") {

                        alert ("Buffalo")


                    else if (animal == "Cow") {

                        alert ("Cow")

                    else if (animal == "Buffalo Calf") {

                        alert ("Buffalo Calf")

                    else if (animal == "Cow Calf") {

                        alert ("Cow Calf")

                    else (

                        alert ("Else")



For next step, i am not aware how to show data for each animal in 2nd dropdown menu...

Your help will be appreciated and Thanks in Advance

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum