<div class="row">
    <div class="col-md-6 col-md-offset-3">
	    <div class="form-group {{ $errors->has('standard_id') ? ' has-error' : '' }}">
            <label class="control-label">Standard <span class="text-danger">*</span></label>
            {!! Form::select('standard_id',$dropdown ,null, ['class' => 'form-control js-example-basic-multiple','required'=>'required','id'=>'standard_id']) !!}
            <span class="help-block" id="error_category_id"><strong>{{ $errors->first('standard_id') }}</strong></span>
        </div>
        <div class="form-group {{ $errors->has('semester_id') ? ' has-error' : '' }}">
            <label class="control-label">Semester <span class="text-danger">*</span></label>
            @if(!empty($semester))
            {!! Form::select('semester_id',['-- Select Semester -- ']+$semester ,null, ['class' => 'form-control js-example-basic-multiple','id'=>'semester_id','required'=>'required']) !!}
            @else
            {!! Form::select('semester_id',['-- Select Semester -- '] ,null, ['class' => 'form-control js-example-basic-multiple','id'=>'semester_id','required'=>'required']) !!}
            @endif
            <span class="help-block" id="error_category_id"><strong>{{ $errors->first('semester_id') }}</strong></span>
        </div>
        <div class="form-group {{ $errors->has('name') ? ' has-error' : '' }}">
            <label class="control-label">Name <span class="text-danger">*</span></label>
            {!! Form::text('name',null, ['class' => 'form-control','required'=>'required']) !!}
            <span class="help-block" id="error_name"><strong>{{ $errors->first('name') }}</strong></span>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $('.js-example-basic-multiple').select2();
    });
    $("body").on("change", "#standard_id", function() {
		var row_id = $(this).val();
        
		$.ajax({
			type: "Get",
			url: "{{ url('admin/getsemester') }}/"+ row_id,
			error: function(result) {},
			success: function(result,semester) {
				if (result.subjects == '') {
					$('#semester_id option').remove();
				} else {
					$('#semester_id option').remove();
					$('#semester_id').append('<option value="">---- Select Semester ----</option>');
					$.each(result, function(key, value) {
						$('#semester_id')
							.append($('<option>', {
									value: key
								})
								.text(value));
					});
				}
				
			}
		});
		
	});

</script>



