Skip to content

Instantly share code, notes, and snippets.

@jesselau76
Created October 3, 2018 21:07
Show Gist options
  • Save jesselau76/e2c1c5980caf05a1ee8d9f44ce951dfd to your computer and use it in GitHub Desktop.
Save jesselau76/e2c1c5980caf05a1ee8d9f44ce951dfd to your computer and use it in GitHub Desktop.
<p>Manticore Search: <input id="manticoresearch" name="search" type="text" /><br />
<button type="button" onclick="displaysort()">Manticore Search</button></p>
<div id="sort" style="display: none;">
<form>
<select name="users" id="sortoption" onchange="search(this.value)">
<option value="1">Sorting by:</option>
<option value="1">Relevance</option>
<option value="2">Latest Date</option>
</select>
</form>
</div>
<div id="searchresult"></div>
<script>
function displaysort() {
var q=document.getElementById("manticoresearch").value;
if (q==""){
return;
}
var x = document.getElementById("sort");
if (x.style.display === "none") {
x.style.display = "block";
}
var sort= document.getElementById("sortoption").value;
search(sort);
}
function search(str) {
if (str=="") {
return;
}
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (this.readyState==4 && this.status==200) {
document.getElementById("searchresult").innerHTML=this.responseText;
}
}
var q=document.getElementById("manticoresearch").value;
//
xmlhttp.open("GET","manticoresearch.php?q="+q+"&sort="+str,true);
xmlhttp.send();
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment