Ich habe ein Formular und eine Liste von Dateinamen. Bei Klick auf einen Dateinamen soll dieser in das Formularfeld eingetragen werden.
Das Funktioniert leider nicht.
Code:
<html>
<head>
<title>Unbenanntes Dokument</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../templates/classic/classic.css" media="screen">
<script type="text/javascript">
function selectImage(url) {
alert(url);
document.getElementById("frmreise2").value = url;
}
</script>
</head>
<body>
<?PHP
$rootdir = "../";
$incdir = "inc/";
require "{$rootdir}{$incdir}config.php";
// Upload Verzeichnis
$uploaddir = "".$rootdir."UPLOAD/";
?>
<!--
Infoboxen Museum Zeigt Informationen für besuchte Museen
Formular zum Anlegen der Infobox Musseum
beim abschicken werden die Daten als Vorlage im Textarea gespeichert
<Infobox Museum:
| Name = Test
| Bild = MuseumXYZ.jpg
| Bildbeschreibung = Museum XYZ
| Ort = Musterdorf
| Art = Kunst
| Breitengrad = 00.00000
/| Längengrad = 00.00000
| Region-ISO = DE
| Webseite = http://www.test.de
>
-->
<form enctype="multipart/form-data" name="frm_infobox">
<table width="80%" border="0" cellpadding="2" cellspacing="2" style="background-color: #F7F7F7; border: 2px solid #FFFFFF; padding: 5px;">
<tr>
<td width="20%" style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;">Name:</td>
<td width="25%" style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;"><input name="frmreise1" type="text" id="frmreise1"></td>
<td rowspan="9" align="left" valign="top" style="width: 100%; padding-bottom: 2px; padding-top: 0px; text-align:left; helvetica; font-size: 11px;">
<?PHP
$verzeichnis = openDir("$uploaddir"); // Öffnet das Upload Verzeichnis
print "<center> <table width=\"95%\" cellpadding=\"2\" cellspacing=\"2\" style='background-color: #FEFFFF; font-size: 10px; border: 2px solid #F2F4F6; padding: 5px;'>";
print "<th colspan='5' style='font-size: 12px; background-color: #FeFeF7; border: 1px solid #890000;'>Medienverzeichnis:</th>";
echo "<tr>";
echo "<td style='font-size: 12px; background-color: #FeFFFF; border: 1px solid #988998;'><strong>Typ:</strong></td>";
echo "<td style='font-size: 12px; background-color: #FeFFFF; border: 1px solid #988998;'><strong>Bildinfos:</strong></td>";
echo "<td style='font-size: 12px; background-color: #FeFFFF; border: 1px solid #988998;'><strong>Filedatum:</strong></td>";
echo "<td colspan='2' style='font-size: 12px; background-color: #FeFeFe; border: 1px solid #988998;'><strong>Aktionen:</strong></td>";
echo "</tr>"; // Link erstellen
while ($file = readDir($verzeichnis)) { // Verzeichnis lesen
if ($file != "." && $file != "..") { // Höhere Verzeichnisse nicht anzeigen!
$ext = strtolower(substr($file, strrpos($file, '.')+1));
if(in_array($ext, $supportedextentions)) {
$icon = $filetypes[$ext];
$img_array = GetImageSize("{$uploaddir}".$file."");
$img_width = $img_array[0];
$img_height = $img_array[1];
if(empty($img_width) || empty($img_height) ){
$bildgroesse = "";
} else {
$bildgroesse = "$img_width px x $img_height px";
}
$groesse = filesize($uploaddir . $file);
$size = number_format(filesize($uploaddir . $file)/1024, 2);
$filedatum = date ("d/m/Y H:i:s.", filemtime($uploaddir . $file));
echo "<tr>";
echo "<td style='border: 1px solid #988998;'>
<img src=\"../images/$icon\" alt=\"File Typ: $ext\"border=\"0\" align='center'/></td>";
echo "<td align='center' style='border: 1px solid #988998;'><strong>$file <br> $bildgroesse ($size KB)</strong></td>";
echo "<td align='center' style='border: 1px solid #988998;'><strong>$filedatum </strong></td>";
// Bild Daten in das Formular schreiben
echo "<td align='center' style='border: 1px solid #988998;'>
<a href=\"javascript:void(0)\" onclick=\"selectImage('../".UPLOAD."".$file."');\">".$uploaddir."".$file."</a></td>";
echo "<td style='border: 1px solid #988998;'>".IMG_DELETE."</td>";
echo "</tr>"; // Link erstellen
}
}
}
print "</table></center>";
closeDir($verzeichnis); // Verzeichnis schließen
?>
</td>
</tr>
<tr>
<td style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;">Bild
Datei:</td>
<td style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;"><input name="frmreise2" type="file" id="frmreise2"></td>
</tr>
<tr>
<td style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;">Bildbeschreibung:</td>
<td style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;"><input name="frmreise2" type="text" id="frmreise2"></td>
</tr>
<tr>
<td style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;">Ort:</td>
<td style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;"><input name="frmreise4" type="text" id="frmreise4"></td>
</tr>
<tr>
<td style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;">Art:</td>
<td style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;"><input name="frmreise5" type="text" id="frmreise5"></td>
</tr>
<tr>
<td style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;">Breitengrad:</td>
<td style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;"><input name="frmreise6" type="text" id="frmreise6"></td>
</tr>
<tr>
<td style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;">Längengrad:</td>
<td style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;"><input name="frmreise6" type="text" id="frmreise7"></td>
</tr>
<tr>
<td style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;">Region-ISO:</td>
<td style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;"><input name="frmreise7" type="text" id="frmreise8"></td>
</tr>
<tr>
<td style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;">Webseite:</td>
<td style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;"><input name="frmreise8" type="text" id="frmreise9"></td>
</tr>
<tr>
<td colspan="3" style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;">
<table width="100%" border="0" style='background-color: #FEFFFF; border: opx solid #ffffff' >
<tr>
<td><input type="submit" name="Submit" value="Abschicken">
<input name="Upload" type="submit" id="Upload" value=" Upload ">
<input type="reset" name="Submit2" value="Zurücksetzen"></td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>