latheesan
04-21-2006, 11:44 AM
hello...
im trying to make a simple chain select drop down list...
basically, the first drop down list will have a list of alphabets, e.g. "A", "B", "C", etc...
then when the user selects "A", the second dropdown list will have a lots of options of names that starts with the letter "A"...
what is the most simplest way of doing this? i came across this site - http://www.yxscripts.com/cs/chainedselects.html, but this one is too complicated for what i want to do :(...
raulgonzalez
04-21-2006, 01:52 PM
Well what I can think of is if you have the names in a database you can do the following.
You might be looking for a javascript though.
<?
echo "the begining of the form";
echo "<select name=whatever>";
//then your sql statement
Select name from Table;
//then within your loop do the following
while row fetch bla bla bla{
$name = "the row name";
$choped_name = substr($name, 0, 1); // chopping to get the first letter
//then compare it with the selection
$variable_name = $_POST['variable_name']; //you would get this from your form
//then check for the first letter of the name
if ($choped_name == "$variable_name"){
echo "<option value={$name}>{$name}";
}
else
{
echo "";
}
}//end of loop or something
echo "</select>";
echo "the rest of the form";
?>
latheesan
04-21-2006, 02:52 PM
hey, thanks for taking your time to reply to my post. I wanted a javascript version. After pulling my hair for hours, i think i worked it out. So, its all good :D
Vdevelopers
04-21-2006, 06:12 PM
Latheesan - if you still need help, send me a PM. I just wrote a script for someone that's a chain select based off a database which you could have if it helped, but it sounds like you have it worked out ;).
The select I did was something that seemed like it would belong on an auction site for classifying a type of good - it was based off of a database populated with categories, category IDs, and each subcategory had a reference to it's parent category and had a value to indicate whether it was a "leaf" or not (leaf being end of the branch).