| Index
» Projekty
» phpMyEdit
» Fórum
» Need to add SELECTED to option in drop-down list |
 |
kally
Založený: 05.01.2005
Príspevky: 14
Zaslal: 2005-07-25 05:50
Návrat hore
Odpovedať s citátom
|
Hello,
I'm using the following code to populate a drop-down list with the names of image files. When I go to the CHANGE view the value in the database needs to be "selected". Right now it is defaulting to '--Select an Enlargement --', not the value from the database. What do I need to add to display the correct value?
$opts['fdd']['image'] = array(
'name' => 'Enlargement Image',
'select' => 'D',
'required' => true,
'sort' => true
);
$opts['fdd']['image']['values']= array('-- Select an Enlargement --');
$maindir = '../art/'. $gallery ;
$mydir = opendir($maindir) ;
$exclude = array( "index.php" , "secret.php") ;
while($fn = readdir($mydir))
{ if ($fn == $exclude[0] || $fn == $exclude[1]) continue;
if ($fn != '.' && $fn != '..')
{
if(!ereg("^tn", $fn))
{
array_push($opts['fdd']['image']['values'],$fn);
}
}
}
closedir($mydir);
Thank you,
Kally
|
kally
Založený: 05.01.2005
Príspevky: 14
Zaslal: 2005-08-11 06:44
Návrat hore
Odpovedať s citátom
|
Well, it seems to be working fine now, so I am guessing I had a typo somewhere and fixed it in the course of working on other stuff. I think the code I posted is correct.
Kally
|
v13
Založený: 28.07.2008
Príspevky: 9
Zaslal: 2008-07-28 21:58
Návrat hore
Odpovedať s citátom
|
Hi, thanks for the code Kally, I've tweaked it just a tad in order the sort the files names alphabetically in the drop down.
-Cheers!
| Kód: |
$opts['fdd']['image'] = array(
'name' => 'Photo',
'select' => 'D',
'maxlen' => 125,
'sort' => true
);
$opts['fdd']['image']['values']= array('-- Select an Image --');
$maindir = '../pets/images/' ;
$mydir = opendir($maindir) ;
$exclude = array( "index.php" , "secret.php") ;
while($fn = readdir($mydir))
{ if ($fn == $exclude[0] || $fn == $exclude[1]) continue;
if ($fn != '.' && $fn != '..')
{
if(!ereg("^tn", $fn))
{
$narray[$i]=$fn;
$i++;
}
}
}
sort($narray);
for($i=0; $i<sizeof($narray); $i++)
{
array_push($opts['fdd']['image']['values'],$narray[$i]);
}
closedir($mydir);
|
|
kally
Založený: 05.01.2005
Príspevky: 14
Zaslal: 2008-10-22 01:49
Návrat hore
Odpovedať s citátom
|
Hey V13,
Thanks for the update on my code! It came in useful today.
Kally
|
|
Odoslať novú tému
Odpovedať na tému
|
|
|
|