Jump to content

Recommended Posts

$html_files = glob("*.htm*");//this will get all htm and html files

$holder = "<select name='file'>\n";

foreach($html_files as $file){
$holder .= "\t<option value='$file'>$file</option>\n";
}

$holder .= "</select>\n";

 

Echo out the $holder variable where you want the dropdown list of html files to show on the page... You can include this in a form, submit it and do stuff with it :-o

*sighs* Copy the WHOLE CODE below straight into the php file, meaning that the only thing in the php file is the code below, no html, no anything.

 

 

<?php
$html_files = glob("*.htm*");//this will get all htm and html files

$holder = "<select name='file'>\n";

foreach($html_files as $file){
$holder .= "\t<option value='$file'>$file</option>\n";
}

$holder .= "</select>\n";

echo $holder;
?>

 

You would want it to re-direct as a new window? Or open in the current window? (Current window seems to be more applicable these days, so do this)

 

<?php
$html_files = glob("*.htm*");//this will get all htm and html files

$holder = "<select name='file' onchange='window.location = this.value;'>\n";

foreach($html_files as $file){
$holder .= "\t<option value='$file'>$file</option>\n";
}

$holder .= "</select>\n";

echo $holder;
?>

Here's the problem with new windows. Ever since the release of tabs in FireFox and IE, opening in a new window almost always opens up in a new tab, defeating the point... If you REALLY want it in a new window... try this (untested, but should work)

 

<?php
$html_files = glob("*.htm*");//this will get all htm and html files

$holder = "<select name='file' onchange=\"window.open(this.value,'mywindow','width=400,height=200,toolbar=yes,
location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,
resizable=yes')\">\n";

foreach($html_files as $file){
$holder .= "\t<option value='$file'>$file</option>\n";
}

$holder .= "</select>\n";

echo $holder;
?>

Let's try with regular links, hmmmm

 

<?php
$html_files = glob("*.htm*");//this will get all htm and html files

$holder = "Current HTML Files on our server:\n<br>";

foreach($html_files as $file){
$holder .= "<a href='$file' target='_blank'>$file</a><br>\n";
}

echo $holder;
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.