Search code examples
htmlsearchsearch-engine

How do I search item on a specific website using my own search bar?


I am trying to search electronic gadgets on a website(http://www.mudah.my/Malaysia/Electronics-for-sale-3000), by using my website search bar. But I don't know how to link my search bar with the one on the website, in order to get the result I wanted.

<!DOCTYPE html>

<html>

<head><title>Seller Evaluation System</title></head>

<body bgcolor="#66ffff">

<h1><center><font color="blue">Seller Evaluation System<center></h1>

    <p><center>
        <form action="http://www.mudah.my/Malaysia/Electronics-for-sale-3000"><input type="search" name="search" size="48" placeholder="Search Electronic Gadgets...">  
        <input type="Submit" name="Search" value="Search"/>         
    </center></p>
</br>

</body>

</html>

Solution

  • You will have to use javascript. There are other options available that you can dynamically change. Something like this

    function searchSite(){
        var inputted=document.getElementById("searchinput").value;
        var searchForm=document.getElementById("searchForm");
      searchForm.action="http://www.mudah.my/Malaysia/Electronics-3000/"+inputted+"-for-sale?lst=0&fs=1&q="+inputted+"y&cg=3000&w=3&so=1&st=s";
      searchForm.submit();
    }
    <form method="get" action="" id="searchForm">
      <input type="text" id="searchinput" >
      <button onclick="searchSite()">Search</button>
      </form>