...

View Full Version : help with a website



nikayla
08-22-2012, 09:59 PM
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.

tom.a
08-23-2012, 07:05 AM
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.

<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/

testerman1
08-26-2012, 08:37 PM
thanks for the script, helpful!

Aug 25, 2012



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum