Hi I have a Laravel Blade template where I built a search function and I want to load a div after the page has reloaded, when I submit the form. Otherwise when the page loads with the results, the results don't show. I want the Javascript to execute while on the page (hide the div), and then when the page refreshes then the div must become visible.
My HTML form is:
<form action="" class="search-form" method="GET" onsubmit="showDiv();">
<input type="text" name="location" placeholder="Search" required>
<button class="search-btn" type="submit"><i class="flaticon-026-search"></i></button>
</form>
And the div I want to show after page load is:
<div id="hideDiv" style="display:none">
@foreach($locations as $location)
@foreach($location->landmark as $landmark)
<p>{{$landmark->name}}</p>
@endforeach
@endforeach
</div>
My JavaScript:
function showDiv() {
var div = document.getElementById("hideDiv");
if (div.style.display == 'none') {
div.style.display = '';
}
else {
div.style.display = 'block';
}
}