On 15 Sep 2004 05:56:10 -0700,
ma**********@hotmail.com wrote:
hi
i have a html pull down list (<SELECT etc etc <OPTION VALUE .....) and
i have the particular value the user last chose it to be in a
$_SESSION['value']. How do i set the selected item of the list to this
one? I can just add it in as the selected item of the list but then it
appears twice. Get me? lol, hope so.
cheers
dave
Put it in a loop:
<?php
$foo = array(
'stuff' => 'for',
'select' => 'box'
);
?>
<select name="foo">
<?php
foreach ($foo as $key => $value) {
?>
<option value="<?php echo $key;?>"
<?php
echo ($_SESSION['value'] == $value) ?
'selected="selected"' :
'';
?>
/>$value</option>
<?php
}
?>
</select>
Formatted above to fit within news client easier.
You can change the line:
echo ($_SESSION['value'] == $value) ?
to
echo ($_SESSION['value'] == $key) ?
if looking for a key match rather than value.
HTH =)
Regards,
Ian
--
Ian.H
digiServ Network
London, UK
http://digiserv.net/