Results 1 to 3 of 3

Thread: Community website, zipcode text box

  1. #1
    Join Date
    Jul 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Community website, zipcode text box

    Hi, I'm trying to create a community website, basically a database of peoples info, sorted by their zip codes.

    What I need is a text box that the user will type their zip code and it takes them to the page for that zip code.

    I'm pretty sure this is possible just don't know how...

    Thanks.

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    You might find this example useful:
    HTML Code:
    <script type="text/javascript">
    window.onload=function()
    {
    document.getElementById('go').onclick=function()
    	{
    	var dom='http://mysite.com/', // Set your web domain
    	inp=document.getElementById('inp'); // ID of textbox that accepts the zip code
    	if(inp.value.match(/(\d)/))
    	location.href=dom+inp.value+'.htm'; // If matches the regex, goes to domain plus [zip].htm
    	else{ // Else informs the user that should be numbers.
    	alert('Numbers please'); 
    	inp.value='';inp.focus();}}}
    </script>
    <label>Your Zip code:</label>
    <input type="text" id="inp"><input type="button" value="Go" id="go">
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. The Following User Says Thank You to rangana For This Useful Post:

    christianc2005 (07-10-2008)

  4. #3
    Join Date
    Jul 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    ok thanks I'll give it a try

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
  •