ragnarok89
asked on
Determine selected element number
Hi All,
I have a dropdown box on a form that lists countries:
My question is, when the form get submitted, I want to know which country was chosen, i.e. the first on the list, or 12th, etc. I need to know the element number. How do I get that value?
Al
I have a dropdown box on a form that lists countries:
$lines =file('./Countries.csv');
foreach($lines as $data) {
list($countriesAr[],$Continent[],$Notify[]) = explode(',',$data);
}
for($i=0;$i<count($countriesAr);$i++) {
echo "<option value='".$countriesAr[$i]."'";
if($_POST['country'] == $countriesAr[$i])
echo "SELECTED";
echo ">".$countriesAr[$i]."</option>\n";
}
My question is, when the form get submitted, I want to know which country was chosen, i.e. the first on the list, or 12th, etc. I need to know the element number. How do I get that value?
Al
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
fishboy2000sd,
Worked like a charm; thank you.
Al
Worked like a charm; thank you.
Al
You are welcome
http://php.net/manual/en/tutorial.forms.php