Post Search by Select Box

HTML

<?php
	get_header();
	get_template_part('inc/banner/page', 'banner');
?>
<div class="space-pd category-page gradient-bg">
	<div class="container">
		<div class="row">
			<div class="col-lg-7 col-xl-8">
					<div class="h2 text-capitalize">New Articles Direct from Our Office</div>
				<div class="category-option">
					<div class="dropdown-select-box">
						<select id="category-select">
							<option value="">Select a category</option>
							<?php $id = get_option( 'page_for_posts'); ?>
							<option value="<?php echo get_the_permalink($id); ?>">Show All</option>
							<?php
							$categories = get_categories();
							foreach ($categories as $category) {
							echo '<option value="' . esc_url(get_category_link($category->term_id)) . '">' . esc_html($category->name) . '</option>';
							}
							?>
						</select>
						<script>
						document.getElementById('category-select').addEventListener('change', function() {
						var selectedCategory = this.value;
						if (selectedCategory) {
						window.location.href = selectedCategory;
						}
						});
						</script>
					</div>
					<div class="searchbox"><?php get_template_part('searchform'); ?></div>
				</div>
				<div class="blog-list">
					<div class="blog-sidebar d-block d-lg-none"><?php get_template_part('searchform'); ?></div>
					<div class="row">
						<?php
							if (have_posts()) :
							while (have_posts()) : the_post();
							get_template_part('inc/blog/blog', 'loop');
							endwhile; wp_reset_postdata();
							endif; wp_reset_postdata();
						?>
					</div>
					<?php
						the_posts_pagination();
						wp_reset_query();
					?>
				</div>
			</div>
			<div class="col-lg-5 col-xl-4">
				<?php // get_sidebar('blog'); ?>
			</div>
		</div>
	</div>
</div>
<script>
jQuery(document).ready(function ($) {
jQuery('.dropdown-select-box select option').each(function(){
var ThisHref = ($(this).attr('value').split('?'))[0];
if(window.location.href.indexOf(ThisHref) > -1) {
jQuery(this).closest('option').attr("selected","selected");;
}
});
});
</script>
<?php get_footer(); ?>