W
wannieb
I am hoping someone can help me in this little problem, I have a php
page with dynamic menu boxes on it.
SCRIPT
*********
<!-- Below are arrays for the two dropdown menus and creates selected
variables so that the selection is seen when posted -->
<?php
$dop = array(
"nbr/2001" => "2001",
"nbr/2002" => "2002",
"nbr/2003" => "2003",
"nbr/2004" => "2004",
"nbr/2005" => "2005",
"nbr/2006" => "2006"
);
$dsop = array(
"/q1nb" => "First Quarter",
"/q2nb" => "Second Quarter",
"/q3nb" => "Third Quarter",
"/q4nb" => "Fourth Quarter",
);
$stickydop = '';
if(isset($_POST['submit'])) {
$stickydop = $_POST['dropdown1'];
}
$stickydsop = '';
if(isset($_POST['submit'])) {
$stickydsop = $_POST['dropdown2'];
}
?>
<!-- End of variable set up -->
<!-- Form consisting of a menu boxes containing the folder arrays from
above, putting selected choice when form is posted -->
<form method="post" name="pickdir">
<select name="dropdown1">
<option value="">Select One</option>
<?php
foreach ($dop as $key => $value){
if($key == $stickydop) {
echo '<option value="' . $key .'" selected>' . $value .
'</option>';
}
else{
echo '<option value="' . $key .'">' . $value . '</option>';
}
}
?>
</select>
<select name="dropdown2">
<option value="">Select One</option>
<?php
foreach ($dsop as $key => $value){
if($key == $stickydsop) {
echo '<option value="' . $key .'" selected>' . $value .
'</option>';
}
else{
echo '<option value="' . $key .'">' . $value . '</option>';
}
}
?>
</select>
<input type="submit" name="submit" value=">>">
<form>
<!-- End of Form -->
<!-- Below produces an array of all file names, which sit within the
directory from the above menu boxes -->
<?php
// The variable below connects the two select menus above into one
path
$dirfile = $dropdown1.$dropdown2;
// The variable below makes only the file extensions listed visible
$pattern = "(\.html$)|(\.htm$)";
if($dir=@opendir($dirfile)){
while(($file=readdir($dir))!==FALSE){
if($file=='..' || $file=='.') continue;
// Registers just the files with the extension listed
if(eregi($pattern,$file))
// Creates array of files with in the folder
$filelist[]=$file;
}
closedir($dir);
}
?>
<!-- End of finding files -->
<!-- Form consisting of a menu box containing the file array from above
-->
<br><br>
<form name="jump2file">
<select name="ofile">
<?php
asort($filelist);
foreach($filelist as $val){
// $valnoext will strip from view the file extensions of the files
in the list
$valnoext = str_replace(array('.html','.htm'),'',$val);
// $dirfile has been put in here so that the javascript picks up the
folder as well as the file name to open
echo '<option value=',$dirfile,'/',$val,'>',$valnoext,'</option>';
}
?>
</select> <br><br>
<input type="button" value="Open" ONCLICK="Jump()">
</form>
<!-- End of Form -->
<!-- Script takes selected file and opens up in window -->
<script>function Jump()
{
location.href = document.jump2file.ofile.value;
}
</script>
<!-- End of script -->
********
I have put echos in the script when testing to make sure the correct
information goes in the php variables, which they all do. The problem
comes when clicking on the final button : <input type="button"
value="Open" ONCLICK="Jump()">
Which runs the javascript, it no longer works, it says
'document.jump2file.ofile' is Null or not an object.
can anyone see where this is going wrong.
page with dynamic menu boxes on it.
SCRIPT
*********
<!-- Below are arrays for the two dropdown menus and creates selected
variables so that the selection is seen when posted -->
<?php
$dop = array(
"nbr/2001" => "2001",
"nbr/2002" => "2002",
"nbr/2003" => "2003",
"nbr/2004" => "2004",
"nbr/2005" => "2005",
"nbr/2006" => "2006"
);
$dsop = array(
"/q1nb" => "First Quarter",
"/q2nb" => "Second Quarter",
"/q3nb" => "Third Quarter",
"/q4nb" => "Fourth Quarter",
);
$stickydop = '';
if(isset($_POST['submit'])) {
$stickydop = $_POST['dropdown1'];
}
$stickydsop = '';
if(isset($_POST['submit'])) {
$stickydsop = $_POST['dropdown2'];
}
?>
<!-- End of variable set up -->
<!-- Form consisting of a menu boxes containing the folder arrays from
above, putting selected choice when form is posted -->
<form method="post" name="pickdir">
<select name="dropdown1">
<option value="">Select One</option>
<?php
foreach ($dop as $key => $value){
if($key == $stickydop) {
echo '<option value="' . $key .'" selected>' . $value .
'</option>';
}
else{
echo '<option value="' . $key .'">' . $value . '</option>';
}
}
?>
</select>
<select name="dropdown2">
<option value="">Select One</option>
<?php
foreach ($dsop as $key => $value){
if($key == $stickydsop) {
echo '<option value="' . $key .'" selected>' . $value .
'</option>';
}
else{
echo '<option value="' . $key .'">' . $value . '</option>';
}
}
?>
</select>
<input type="submit" name="submit" value=">>">
<form>
<!-- End of Form -->
<!-- Below produces an array of all file names, which sit within the
directory from the above menu boxes -->
<?php
// The variable below connects the two select menus above into one
path
$dirfile = $dropdown1.$dropdown2;
// The variable below makes only the file extensions listed visible
$pattern = "(\.html$)|(\.htm$)";
if($dir=@opendir($dirfile)){
while(($file=readdir($dir))!==FALSE){
if($file=='..' || $file=='.') continue;
// Registers just the files with the extension listed
if(eregi($pattern,$file))
// Creates array of files with in the folder
$filelist[]=$file;
}
closedir($dir);
}
?>
<!-- End of finding files -->
<!-- Form consisting of a menu box containing the file array from above
-->
<br><br>
<form name="jump2file">
<select name="ofile">
<?php
asort($filelist);
foreach($filelist as $val){
// $valnoext will strip from view the file extensions of the files
in the list
$valnoext = str_replace(array('.html','.htm'),'',$val);
// $dirfile has been put in here so that the javascript picks up the
folder as well as the file name to open
echo '<option value=',$dirfile,'/',$val,'>',$valnoext,'</option>';
}
?>
</select> <br><br>
<input type="button" value="Open" ONCLICK="Jump()">
</form>
<!-- End of Form -->
<!-- Script takes selected file and opens up in window -->
<script>function Jump()
{
location.href = document.jump2file.ofile.value;
}
</script>
<!-- End of script -->
********
I have put echos in the script when testing to make sure the correct
information goes in the php variables, which they all do. The problem
comes when clicking on the final button : <input type="button"
value="Open" ONCLICK="Jump()">
Which runs the javascript, it no longer works, it says
'document.jump2file.ofile' is Null or not an object.
can anyone see where this is going wrong.