content logo

Bootstrap Search Boxes:

Bootstrap Search Box in a Modal

Do want to have a website that stands out among the rest of them on the Internet? The more unique and different you make your website, the more people would visit it and you get more revenue from it. since search boxes are one of the most commonly used elements in every website, you should try to design the coolest model possible to ensure your visitors enjoy it. there are many models available for you to try out there but one of the most efficient ones is a Bootstrap search with Modal. These search boxes take up little physical space and don’t need any redesigning if you already have your website built.

In this post, we have a Modal Search result code to help you design the best search box for your website. This is a special method of searching with a smart search feature implemented in it. whenever you click the search button a Modal Search box will appear in a new window and you can type in your search input. You have got 3 radio boxes in this Bootstrap search box which you can tick to search. Also, pressing the search button will do the actual search. You can get this CSS Modal box right now for free.

#

Modal Search Result

#

CSS Modal Box

#

Bootstrap Search Box

#

Bootstrap Search with Modal

<!-- This script got from frontendfreecode.com -->
<div class="container">
    <h4>Click to search the site</h4>
    <!-- Trigger the modal with a button -->
    <button type="button" class="btn btn-info btn-md" data-toggle="modal" data-target="#myModal">Search</button>
    <!-- Modal -->
    <div class="modal fade" id="myModal" role="dialog">
        <div class="modal-dialog">
            <!-- Modal content start-->
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">Tormach Global Search</h4>
                </div>
                <div class="modal-body">
                    <form name="jksearch" action="http://www.google.com/search" target="_blank" method="get" onSubmit="jksitesearch(this)">
                            Type a keyword or Phrase:<br />
                            <input id="hiddenquery" type="hidden" name="q" />
                            <input name="qfront" type="text" style="width: 200px" value="" /> <input type="submit" value="Search" /><br />
                            <div style="font: bold 11px Verdana;">
                                Google:<input name="se" type="radio" checked> Yahoo:<input name="se" type="radio"> Bing:<input name="se" type="radio">
                            </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>
</div><a style="font-size: 8pt; text-decoration: none" target="_blank" href="http://frontendfreecode.com">Free Frontend</a>
                                                                            
var domainroot = "www.frontendfreecode.com"
//---------Vars for the engine--------------------------->
var searchaction = [ //form action for the 3 search engines
    "http://www.google.com/search",
    "http://search.yahoo.com/search",
    "http://search.msn.com/results.aspx"
]
var queryfieldname = ["q", "p", "q"] //name of hidden query form for the 3 search engines
function switchaction(cur, index) {
    cur.form.action = searchaction[index]
    document.getElementById("hiddenquery").name = queryfieldname[index]
}
function jksitesearch(curobj) {
    for (i = 0; i < document.jksearch.se.length; i++) { //loop through radio to see which is checked
        if (document.jksearch.se[i].checked == true)
            switchaction(document.jksearch.se[i], i)
        document.getElementById("hiddenquery").value = "site:" + domainroot + " " + curobj.qfront.value
    }
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- This script got from frontendfreecode.com -->

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
    <h4>Click to search the site</h4>
    <!-- Trigger the modal with a button -->
    <button type="button" class="btn btn-info btn-md" data-toggle="modal" data-target="#myModal">Search</button>
    <!-- Modal -->
    <div class="modal fade" id="myModal" role="dialog">
        <div class="modal-dialog">
            <!-- Modal content start-->
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">Tormach Global Search</h4>
                </div>
                <div class="modal-body">
                    <form name="jksearch" action="http://www.google.com/search" target="_blank" method="get" onSubmit="jksitesearch(this)">
                            Type a keyword or Phrase:<br />
                            <input id="hiddenquery" type="hidden" name="q" />
                            <input name="qfront" type="text" style="width: 200px" value="" /> <input type="submit" value="Search" /><br />
                            <div style="font: bold 11px Verdana;">
                                Google:<input name="se" type="radio" checked> Yahoo:<input name="se" type="radio"> Bing:<input name="se" type="radio">
                            </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>
</div><div id="bcl"><a style="font-size:8pt;text-decoration:none;" href="http://www.devanswer.com">Free Frontend</a></div>
<script>
var domainroot = "www.frontendfreecode.com"
//---------Vars for the engine--------------------------->
var searchaction = [ //form action for the 3 search engines
    "http://www.google.com/search",
    "http://search.yahoo.com/search",
    "http://search.msn.com/results.aspx"
]
var queryfieldname = ["q", "p", "q"] //name of hidden query form for the 3 search engines
function switchaction(cur, index) {
    cur.form.action = searchaction[index]
    document.getElementById("hiddenquery").name = queryfieldname[index]
}
function jksitesearch(curobj) {
    for (i = 0; i < document.jksearch.se.length; i++) { //loop through radio to see which is checked
        if (document.jksearch.se[i].checked == true)
            switchaction(document.jksearch.se[i], i)
        document.getElementById("hiddenquery").value = "site:" + domainroot + " " + curobj.qfront.value
    }
}
</script>

</body>
</html>
Preview