Forum Moderators: coopster
Here's the dropdown menu...
<SELECT NAME="NameSuffix">
<OPTION VALUE="">SUFFIX</OPTION>
<OPTION VALUE=""></OPTION>
<OPTION VALUE="Jr.">Jr.</OPTION>
<OPTION VALUE="Sr.">Sr.</OPTION>
<OPTION VALUE="M.D.">M.D.</OPTION>
<OPTION VALUE="Ph.D">Ph.D</OPTION>
<OPTION VALUE="I">I</OPTION>
<OPTION VALUE="II">II</OPTION>
<OPTION VALUE="III">III</OPTION>
</SELECT>
<?php print("$data[6]");?> Gets me the database value from the NameSuffix field. Let's say, for example the value is "Sr.". What do I have to do to get the option menu to have the correct value selected from that?
$option_values = array('Jr.','Sr.','M.D.','Ph.D.','I','II','III');
Then, your select statement would look something like:
<select name="NameSuffix">
<option value="">SUFFIX</option>
<option value=""></option>
<?php
foreach($option_values as $id=>$value){
$sel = ($value == $data[6])? 'selected="selected"' : '';
echo "<option $sel value=\"$value\">$value</option>";
}
?>
</select>
Hope that helps ....
-sned
<?
$select = array("", "Jr.", "Sr.", "M.D.", "Ph.D", "I", "II", "III");
?>
<SELECT NAME="NameSuffix">
<OPTION VALUE="">SUFFIX</OPTION>
<?
foreach($select as $value){
echo "<OPTION VALUE=\"$value\"";
if ($value == $data[6]) echo "SELECTED";
echo ">$value</OPTION>";
}?>
</SELECT>
I don't know of any other way to do that except to use javascript
Best regards
Michal Cibor
PS Sned was faster than me:)