mercredi 29 mars 2017

internal site search and return results in separate web page

Hello and thanks for your help in advance.

I want to make an internal search capability on my web site.

A user enters a keyword in the search field and after they press enter, the result are shown on a separate web page. So if someone enters the word cat, all the web pages on my web site will be populated in a list with hyperlinks to the pages. I want this to only search my site, no google search engines.

I want to make this in the simplest way possible to php no python, just javascript.

I attempted to make it happen but this code just takes me to a page that has the word i searched for on it.

<div id="widget-user">

    <form id="siteSearch" method="get" action="http://ift.tt/1qlTgqT">
        <input type="text" id="searchInput" name="q" maxlength="20">
        <input type="submit" value="Search">
    </form>

    <script>

        var a = document.getElementById("siteSearch");
        a.addEventListener("submit", function(event) {

            event.preventDefault();
            var b = document.getElementById("searchInput").value;
            window.location.href = "http://ift.tt/1qlTgqT" + b;

        });

    </script>




Aucun commentaire:

Enregistrer un commentaire