SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Quick search box

    I am building a "quick search" navigation box to display "I wants" in a drop-down list, so people can click what they want and be taken to an appropriate page. So far I have:
    Code:
     <form name="quicksearch">
    <select name="search">
    <option name="this" value="this">I want this url.</option>
    <option name="that" value="that">I want that url.</option>
    <option name="another" value="another">I want another url.</option>
    </select>
    </form>
    Where do I put the url's and how make it clickbable without the "Submit" button?
    Paul C.
    ClickBasics
    http://www.clickbasics.com

  2. #2
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So like an javascript jump box?
    I think this is exactly waht you want.
    http://www.mcfedries.com/JavaScript/linklist.asp

  3. #3
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Yeah...you could try javascript. I haven't tried that yet, but here goes...

    Put this code into the <head> of your page :

    <script type="text/javascript">
    <!--
    function redirect()
    {
    window.location = "http://www.google.com"
    }
    //-->
    </script>
    And then do the following to each selection :

    <option onclick="return redirect()" value="This URL">This URL</option>
    You will notice that the first part of code above contains a function which is named 'redirect()' and points to a specific URL. You could create a function for each <option> tag.

    Hope this helps.

  4. #4
    Carpe Diem = Fish of the Day fisherboy's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use the very simple javascript on this page if you like. It's very straightforward and validates.
    fisherboy
    Web Site Design

  5. #5
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi fisherboy,

    I was also interested in something like this so..once again you've been a big help (I guess I should just follow you all over Sitepoint to learn --PS I'm NOT A STALKER LOL!--)

    I do have one question though, where is the argument 'this' coming from when you call the function--I am familiar with C++ and it looks like you are passing it a variable called 'this' however I cant find where 'this' is being set?

    Thanks!
    Bill

  6. #6
    Carpe Diem = Fish of the Day fisherboy's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Bill

    If you follow me everywhere we will soon be very, very lost!

    The code has been copied and pasted from a help site on the internet (if memory serves me it was from Bravenet). I chose it because it seemed the simplest.

    Unfortunately my understanding of javascript is so close to nil you can hardly tell the difference. All I can tell you is that it works. You may like to post it in the Javascript Forum for some expert comment?

    Cheers
    fisherboy
    Web Site Design

  7. #7
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys for the options above. After working with them a while, I found the following that does just what I want:
    Code:
    <form name="jump1">
    <select name="myjumpbox"
    OnChange="location.href=jump1.myjumpbox.options[selectedIndex].value">
    	 <option selected>Please Select...
    	 <option value="/about/10/">accommodations</option>
    	 <option value="/about/287/">arrival and departure</option> 
    	 <option value="/healing_arts/138/">ayurveda at kripalu</option> 
    <option value="/program/program/proftraining/cec/">CE credits</option> 
    </select>
    </form>
    adapted from:
    http://www.davesite.com/webstation/js/theory1jump.shtml
    Paul C.
    ClickBasics
    http://www.clickbasics.com

  8. #8
    Non-Member Egor's Avatar
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    7,305
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Paul, just make sure you add some <noscript></noscript> content below (either a button, or a <ul> of all the locations).

  9. #9
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Egor,

    Re:
    Paul, just make sure you add some <noscript></noscript> content below (either a button, or a <ul> of all the locations).
    What will that do for me? Seems to work fine as is. Please provide example code.
    Paul C.
    ClickBasics
    http://www.clickbasics.com

  10. #10
    Carpe Diem = Fish of the Day fisherboy's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Paul

    The NOSCRIPT element allows authors to provide alternate content when a script is not executed. Just means that people without js will get to view an alternative and not be penalised for visiting your site.

    Some people disable javascript to avoid pop-ups and other nasties. Others may be using text only readers. Some corporates disable it as a security precaution. Apparently at least 6 in every 100 users disable js for some reason.

    I disabled it when overseas using very expensive connections to help reduce my bandwidth use.

    Hope this helps.....
    fisherboy
    Web Site Design

  11. #11
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Fisherboy,
    Yes, that helps. I tried looking at the jump boxwith JavaScript disabled. The main menu also depends on JavaScript. This did not display correctly, however the jump box DID. Would you have any idea why the jump box would still display correctly with JavaScript disabled?
    Paul C.
    ClickBasics
    http://www.clickbasics.com

  12. #12
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Fisherboy,

    Aha! The jump box displays correctly, but the links do not work when JavaScript is disabled. I added a <script></noscript> alert:
    JavaScript must be enabled in your browser to view this website.
    Thanks for the help.
    Paul C.
    ClickBasics
    http://www.clickbasics.com

  13. #13
    Carpe Diem = Fish of the Day fisherboy's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paulcj2
    Fisherboy,

    Aha! The jump box displays correctly, but the links do not work when JavaScript is disabled. I added a <script></noscript> alert:Thanks for the help.
    I guess you mean <noscript></noscript>?

    I'm pleased it's working Paul. Have fun!
    fisherboy
    Web Site Design

  14. #14
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Re:
    I guess you mean <noscript></noscript>?
    Yes. Many thanks.
    Paul C.
    ClickBasics
    http://www.clickbasics.com


Bookmarks

Posting Permissions

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