Oto kod JS w headzie:
Kod
<script language="javascript">
<!--
/*Combo Box Image Selector:
By JavaScript Kit (www.javascriptkit.com)
Over 200+ free JavaScript here!
*/
function showimage()
{
if (!document.images)
return
document.images.pictures.src=
document.mygallery.picture.options[document.mygallery.picture.selectedIndex].value
}
//-->
</script>
<!--
/*Combo Box Image Selector:
By JavaScript Kit (www.javascriptkit.com)
Over 200+ free JavaScript here!
*/
function showimage()
{
if (!document.images)
return
document.images.pictures.src=
document.mygallery.picture.options[document.mygallery.picture.selectedIndex].value
}
//-->
</script>
Kod combo boxa:
Kod
<?php
//specify path of directory
$dir = 'obrazki/';
//open directory
if ($handle = opendir($dir))
{
//read each file
while ($file = readdir($handle)) {
//only get files of a particular type
//eliminate additional directories
if ($file != "." && $file != "..")
{
//store filename in array
$option[] = $file;
}
}
//close directory
closedir($handle);
//create combo box
$cbo = '<form name="mygallery">';
$cbo = '<select name="picture" onChange="showimage()>';
//create option for each file
foreach($option as $key=>$val)
{
$cbo .='<option selected value="obrazki/'.$val.'">'.$val.'</option>';
}
//close combo box
$cbo .= '</select>';
$cbo .= '</form>';
//output combo box (might want to put this in a form tag on your final page)
echo $cbo;
}
?>
<img src="obrazki/shellac.jpg" name="pictures" width="99" height="100">
//specify path of directory
$dir = 'obrazki/';
//open directory
if ($handle = opendir($dir))
{
//read each file
while ($file = readdir($handle)) {
//only get files of a particular type
//eliminate additional directories
if ($file != "." && $file != "..")
{
//store filename in array
$option[] = $file;
}
}
//close directory
closedir($handle);
//create combo box
$cbo = '<form name="mygallery">';
$cbo = '<select name="picture" onChange="showimage()>';
//create option for each file
foreach($option as $key=>$val)
{
$cbo .='<option selected value="obrazki/'.$val.'">'.$val.'</option>';
}
//close combo box
$cbo .= '</select>';
$cbo .= '</form>';
//output combo box (might want to put this in a form tag on your final page)
echo $cbo;
}
?>
<img src="obrazki/shellac.jpg" name="pictures" width="99" height="100">
Po wybraniu opcji nic się nie dzieje.
Proszę o pomoc.
Pozdrawiam