PDA

View Full Version : Javscript Problems



Romanity
26-05-2008, 12:56 PM
I hate using java, but ive kinda been forced into using it for this... Right at the moment, it populates a select field with all the images in a directory..... however when the form is submitted to the database, it doesnt save as "name_of_image.gif" it will save as "Name"... so how do I change this, heres the part of the script I believe affect this...



<?
Header("content-type: application/x-javascript");
$pathstring=pathinfo($_SERVER['PHP_SELF']);
$locationstring="http://" . $_SERVER['HTTP_HOST'].$pathstring['dirname'] . "/";
function returnimages($dirname=".") {
$pattern="(\.jpg$)|(\.png$)|(\.jpeg$)|(\.gif$)";
$files = array();
$curimage=0;
if($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))){
if(eregi($pattern, $file)){
echo 'picsarray[' . $curimage .']="' . $file . '";';
$curimage++;
}
}
closedir($handle);
}
return($files);
}
echo 'var locationstring="' . $locationstring . '";';
echo 'var picsarray=new Array();';
returnimages()
?>




function populateSelect(selectobj){
for (var i=0; i<picsarray.length; i++)
selectobj.options[selectobj.options.length]=new Option(picsarray[i], picsarray[i])
if (selectobj.options.length>1){
selectobj.selectedIndex=0
showpicture(document.getElementById("picsform").picslist)
}
}

Protege
26-05-2008, 03:56 PM
I've read it a few times and I still dont get what you mean... Also java and javascript are completely different languages.

Want to hide these adverts? Register an account for free!