Webracer
|
| Posted: 07/15/2003, 3:37 AM |
|
I tried to fill up a listbox in CCS. Most is working fine but I always get only one file in my listbox. Can someone help me out?
global $NewRecord1;
//define the path as relative
$path = "images/";
$dummy = 1;
//using the opendir function
$dir_handle = @opendir($path) or die("Directory $path not found");
$files["$file"] = array();
//running the while loop
while ($file = readdir($dir_handle))
{ if($file != '.' && $file != '..')
$files[$dummy] = $file;
$dummy = $dummy + 1;
}
//closing the directory
closedir($dir_handle);
$NewRecord1->ListBox2->Values = array(array_values($files));
|
|
|
 |
Headhunter
|
| Posted: 07/15/2003, 2:16 PM |
|
look at this article: http://www.gotocode.com/art.asp?art_id=241&
I used this in my project (CCS2 + php + MySQL), and code looks like this:
global $settings;
$theme2=$settings->theme->GetValue();
$default_dir = "Themes/";//Dir path You want to list
$settings->theme_dir->SetValue("<select name=\"file2\" onchange=\"updateThemeField()\">");
$settings->theme_dir->SetValue($settings->theme_dir->GetValue() . "<option SELECTED value=\"" . $theme2 . "\">" . $theme2 );
if(!($handle = opendir($default_dir))) die("Cannot open $default_dir.");
while(false !== ($file = readdir($handle)))
{
if($file != '.' && $file != '..')
{
$settings->theme_dir->SetValue($settings->theme_dir->GetValue()
. "<option value=\"" . $file . "\">" . $file
);
}
}
closedir($handle);
$settings->theme_dir->SetValue($settings->theme_dir->GetValue() . "</select>");
echo'
<script language="JavaScript">
function updateThemeField() {
var v = document.settings.file2.selectedIndex;
var x = document.settings.file2[v].value;
document.settings.theme.value=x;
}
</script>';
|
|
|
 |
Webracer
|
| Posted: 07/16/2003, 3:45 AM |
|
Headhunter,
I tried your code but I do something wrong. Is it possible to send a simple CCS-project as example toinfo@c21.be ?
|
|
|
 |
|