Results 1 to 2 of 2

Thread: Search box code in html

  1. #1
    Join Date
    Nov 2012

    Search box code in html

    hello all,
    I am looking for some code to add to the one below...what i would like to do is be able to type in a word such as "contact" in a search box click go and have it take me to the contact page...the code below does do that but how can i repeat it with more links and keywords.

    so in a nut shell i would like to enter keywords in the search box and have it take me to a specific page

    thanks in advance

    <form id="search" action="http://websitedesignsonly99dollars.weebly.com/contact.html">
    <input name="contact""about" type="contact" size="20" />
    <a href="http://websitedesignsonly99dollars.weebly.com/contact.html">Search</a>

  2. #2
    Join Date
    Aug 2012
    This can't be done in just HTML, you need to use PHP. Your form will obviously take you to the contact page as that is where the form data is sent to (specified in your form action). Also, you don't need a link for your Search as this should be a submit button which will then go to the page specified in your form action.

    The basics of your form would be

    HTML Code:
    <form id="search" method="post" action="search.php">
    <input name="keyword" type="text" size="20" />
    <input type="submit" name="submit" valeu="Search">
    And then on search.php you will need to get the value of $_POST['keyword'] and either query a list of pages in a database or in an array and if it exists redirect the person to that page. I cannot give you the code as it depends on how you plan for this to work and if you know PHP.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center