I have a search box on my website. And it was working fine, but suddenly stopped working when i added my websites video page. I keep getting an error saying "Uncaught ReferenceError: search is not defined" and i can't seem to find what the error is
Header.php
<center>
<input type="text" id="searchbar" onkeydown="search()" style="width:60%;font-size:17px;font-weight:bold; height:40px; padding:0px 10px; margin:3px 0px 0px 0px; border-radius:15px;" placeholder="Search for People, Videos, #hashtags and Blogs..." value="<?php echo $search; ?>"/>
</center>
And my footer page: footer.php
function search(){
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13'){
var str = post = document.getElementById("searchbar").value;
if(str.indexOf("#") == 0){
var result = str.replace('#', '');
var result = result.replace(/ /g, '%20');
window.location.assign("http://www.daparadise.com/testing/daparadise2/search.php?type=hashtag&search=" + result);
}else if(str.indexOf("people named") == 0){
var result = str.replace('people named ', '');
var result = result.replace(/ /g, '%20');
window.location.assign("http://www.daparadise.com/testing/daparadise2/search.php?type=people&search=" + result);
}else if(str.indexOf("videos") == 0){
var result = str.replace('videos ', '');
var result = result.replace(/ /g, '%20');
window.location.assign("http://www.daparadise.com/testing/daparadise2/search.php?type=videos&search=" + result);
}else if(str.indexOf("blogs") == 0){
var result = str.replace('blogs ', '');
var result = result.replace(/ /g, '%20');
window.location.assign("http://www.daparadise.com/testing/daparadise2/search.php?type=blogs&search=" + result);
}else{
var result = result.replace(/ /g, '%20');
window.location.assign("http://www.daparadise.com/testing/daparadise2/search.php?type=web&search=" + result);
}
}
}