Re: include a file

From: Date: Mon, 16 Feb 2004 14:07:29 +0000
Subject: Re: include a file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-177799@lists.php.net to get a copy of this message
Angelo Zanetti wrote:
Hi, is it possible to include a file from when a select's onChange is called ie: <select name="prospects" onChange="include(editBottom.inc);"> if its possible what would be the best way to do this?? thanx
It is, but you have to reload the page and pass the filename as request variable: <?php $allowed_files = array('editBottom.inc' => 'Bottom', 'editTop.inc' => 'Top'); ?> <form action="script.php"> <select name="prospects" onChange="this.form.submit();"> <?php foreach($allowed_files as $key => $name) echo "<option value=\"$key\">$name</option>\n"; ?> </select> <input type="submit" value="&gt;&gt;"><!-- for nonjavascript brobsers --> </form> <?php if(array_key_exists($_GET['prospects'], $allowed_files)) { include($_GET['prospects']); } ?> HTH

« previous php.general (#177799) next »