Results 1 to 4 of 4

Thread: Checkbox search

  1. #1
    Woolwich is offline Hello World
    Join Date
    Sep 2011
    Posts
    2

    Default Checkbox search

    Hello!

    I'm trying to add a checkbox search function on my Wordpress website but I'm a bit stuck (my PHP and Wordpress coding skills is not the best). I have tried this:

    Code:
    <input type="checkbox" value="car" name="s" id="s" /> Car <br />
    <input type="checkbox" value="bike" name="s" id="s" /> Bike <br />
    
    <input type="submit" id="searchsubmit" value="Search" />
    But it only allows me to search for one of the phrases even though I check both the checkboxes. Also I can't use it together with the regular text input search field, again it only allows me to search for one of the phrases. If I write Bus in the text input search field and check both the checkboxes I want the search function to show posts/pages that contains both Bus, Car and Bike. Is it possible to do that in some way?

    /Woolwich

  2. #2
    PressedIn's Avatar
    PressedIn is offline Hello World
    Join Date
    Sep 2011
    Location
    Jonhnson City, TN
    Posts
    28

    Default

    IIRC you're only supposed to define an ID once, seeing as the actual search box already utilizes the ID, you would need to configure it to where the ID's of the additional form fields are different, the same for name. In the above example, you're using the same name and ID for both which is most likely confusing the search request and causing it to randomly select one of the items to search on.
    Jonathan T. - PressedIn
    Managed WordPress Hosting, for Free
    .
    twitter: @pressedin - gtalk & email: hello [at] pressed.in

  3. #3
    Woolwich is offline Hello World
    Join Date
    Sep 2011
    Posts
    2

    Default

    Ah, I should have thought of that. As I wrote I'm a very unexperinced coder. :)

    I have figured out how to post the checkbox values now but they don't affect the search result (only the input with the id "s" does). I guess I have to use $_GET somewhere to make the inputs with other id's to affect the search results - but where do I use $_GET?

    Also - sorry for my bad english, I hope you guys understand what I'm writing. :)

  4. #4
    Jeffro's Avatar
    Jeffro is offline WPTavern Forum Admin
    Join Date
    Jan 2009
    Location
    Ohio
    Posts
    2,359

    Default

    Hey Wool, this particular plugin sounds like it could possibly steer you in the right direction, or at least change the direction you were heading.

    http://wordpress.org/extend/plugins/search/

    Not sure how it works but it was a Google Summer of Code project.

Posting Permissions

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