I have a custom search bar but I don't know how to get it to function with a js code.
This is my Search Button:
script type = "text/javascript" >
document.getElementById('searchform').onsubmit = function() {
window.location = 'http://www.google.com/search?q=site:yourdomainname ' + document.getElementById('test').value;
return false;
}
<!DOCTYPE html>
<center>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
input[type=text] {
width: 130px;
box-sizing: border-box;
border: 2px solid #000000;
border-radius: 4px;
font-size: 16px;
background-color: white;
background-image: url('searchicon.png');
background-position: 10px 10px;
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;
}
input[type=text]:focus {
width: 100%;
}
</style>
</head>
<body>
<form>
<input type="text" name="search" placeholder="Search..">
</form>
</body>
</html>
If you can help me that would be great, thank you.