Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2010
    Location
    North Fort Myers, FL
    Posts
    20
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Location list sort

    We list our branches on our webpage, but I want people to be able to search for the nearest ones.

    This is the form I built as a place holder... but I'm sure I need a "little something" to go along with it. ha ha ha.

    Code:
    <form class="login">
    		  &nbsp <label class="white"><b>Zip Code</b><br />
    		  &nbsp <input name="zip" type="text" maxlength="5" size="10"/>
    		  </label>
      	
    	    <br /><br />
      
    		<label>
        
    	    &nbsp <input type="submit" name="submit" id="submit" value="Go!" class="btn" />
    	    </label>
    		</form>
    I would like to sort them in order of closest to furthest (or even just display the top 5)... where would I find something like that?

    I seem to be having a difficult time with my searches in google and otherwise.

    Anyone have any ideas?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,548
    Thanks
    77
    Thanked 4,382 Times in 4,347 Posts
    Not a task for JavaScript. Needs to be done server-side.

    Possible exception: If you only have a handful of branches and you only have a relatively few zip codes you care about people entering (that is, if you only have branches in Connecticut and you don't allow zip codes outside that state), you *could* then do it in JS coding.

    But in general, getting distance and/or nearest location based on zip code is best left to server-side processing. It's almost always done via a database query.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,548
    Thanks
    77
    Thanked 4,382 Times in 4,347 Posts
    Here's an example demo I put together a few years back, using ASP server-side code:
    http://www.clearviewdesign.com/newbie

    It just shows all zip codes close to a given zip code, but would be easy to adapt to stores/branches close to a given zip, instead.

    http://www.clearviewdesign.com/Newbi...AndMapDemo.asp
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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