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 to the CF scene
    Join Date
    Aug 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help with a website

    I need help or pointed in the right direction please!

    I am trying to develop a website. On this website, I need users to be able to choose options, and based on the options they have chosen, it will bring up results fitting those choices. If that makes sense?

    For example a user might be looking for rock climbing locations in a particular city, based on what city they choose it will then bring up the results of the nearby places.

    I have no idea how to build a funtion like that.

  • #2
    New Coder
    Join Date
    Jun 2011
    Posts
    17
    Thanks
    0
    Thanked 3 Times in 3 Posts
    It depends on how much data you have. If you dont have much data you can use javascript. Here is a script I wrote that populates a list using the selection box.
    Code:
    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
    <script>
    	$(function(){
    		places = [{city: 'Auckland', place: 'Sky Tower'},{city: 'Auckland', place: 'Piha'},{city: 'Wellington', place: 'Te Papa'}]
    		$('.city').change(function(){
    			var city = $(this).val();
    			$('.selectedCity').html('<a>'+city+':</a>');
    			$('.results').html('');
    			$.each(places, function(index, value){
    				if(value.city == city){
    					$('.results').append('<li>'+value.place+'</li>');
    				}
    			});
    		});
    	});
    </script>
    </head>
    <body>
    		<select class="city">
    			<option>Auckland</option>
    			<option>Hamilton</option>
    			<option>Tauranga</option>
    			<option>Wellington</option>
    			<option>Christchurch</option>
    		</select>
    		<p class="selectedCity"></p>
    		<ul class="results"></ul>
    </body>
    </html>
    If you have a large amount of data, you may want to store the data in a database and use a php script to retrieve the data and display it in the browser. check out these tutorials for information on PHP and MySQL:
    http://www.tizag.com/phpT/
    http://www.tizag.com/mysqlTutorial/

  • #3
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks for the script, helpful!

    Aug 25, 2012


  •  

    Posting Permissions

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