Headhunter
|
| Posted: 05/12/2003, 3:00 PM |
|
Project: PHP + MySQL + CCS 2.0
The thing I want to do is create a listbox who's selected content is to be stored in a database and is populated from the filesystem's directory structure.
It is not necesary to have all subdirs and files in it.
I want to use it to select all subdirs of a specified folder, for example al the subfolders in the folder Themes/
Thanks in advance.
http://www.dbweaver.com
|
|
|
 |
Headhunter
|
| Posted: 05/12/2003, 11:56 PM |
|
Experimented myself but doesn't work.
I adapted Feha's sollution for CC, http://www.gotocode.com/art.asp?art_id=241&
but I can't manage to get it work correctly in CCS. I only get 1 item in my listbox. I'm sure I do something wrong since I'm bad at coding.
global $settings;
$fldlogo_dir_1=("<select name=\"file2\" onchange=\"updateHLogoField()\">");
$logo2=$settings->hot_pic->GetValue();
$fldlogo_dir_2=("<option SELECTED value=\"" . $logo2 . "\">" . $logo2 );
$default_dir = "Themes/";//Dir path You want to list
if(!($dp = opendir($default_dir))) die("Cannot open $default_dir.");
while($file = readdir($dp))
if($file != '.' && $file != '..')
$fldlogo_dir_3=("<option value=\"" . $default_dir . $file . "\">" . $default_dir . $file );
closedir($dp);
$fldlogo_dir_4=("</select>");
$settings->logo_dir->SetValue("$fldlogo_dir_1 $fldlogo_dir_2 $fldlogo_dir_3 $fldlogo_dir_4");
echo'
<script laguage="JavaScript">
function updateHLogoField() {
var v = document.vto_hot.file2.selectedIndex;//You have to adjust to feet your forms name and field
var x = document.vto_hot.file2[v].value;//You have to adjust to feet your forms name and field
document.vto_hot.hot_pic.value=x;//You have to adjust to feet your forms name and field
}
</script>';
|
|
|
 |
Headhunter
|
| Posted: 05/13/2003, 8:01 AM |
|
I did a little debugging myself and came to this result:
The only thing that I now have to know is how to make the SetValue parts appear in my html page, and not just the latest one. I don't know how to do that. I think when I can manage that, then it should work.
global $settings;
$settings->logo_dir->SetValue("<select name=\"file2\" onchange=\"updateHLogoField()\">");
$logo2=$settings->hot_pic->GetValue();
$settings->logo_dir->SetValue("<option SELECTED value=\"" . $logo2 . "\">" . $logo2 );
$default_dir = "Themes/";//Dir path You want to list
if(!($handle = opendir($default_dir))) die("Cannot open $default_dir.");
while(false !== ($file = readdir($handle)))
{
if($file != '.' && $file != '..')
{
$settings->logo_dir->SetValue("<option value=\"" . $default_dir . $file . "\">" . $default_dir . $file );
}
}
closedir($handle);
$settings->logo_dir->SetValue("</select>");
echo'
<script laguage="JavaScript">
function updateHLogoField() {
var v = document.settings.file2.selectedIndex;
var x = document.settings.file2[v].value;
document.settings.hot_pic.value=x;
}
</script>';
|
|
|
 |
|