You have to put the variable into a hidden form element or tack it onto a
URL in order to pass it to the PHP page.

---John Holmes...

----- Original Message -----
From: "Mihaela Dupret" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, May 28, 2002 6:51 AM
Subject: [PHP] onchange read file, php & JS


Hy,

Is it possible to use a javascript variable into php or
to change it into php variable?

I have a list with the files from a directory, this works
fine. For the event onchange I want to show the content of
the file chosen.

So, in the code, the variable "inputf" has the file name
that I want to read. How can I use it in the code php?

Thanks a lot!

Mihaela

<form name=showfile>
<SELECT NAME=Types onChange="javascript:FileContenu
(this.form)">
<OPTION SELECTED value="choisir">- Choisissez -

<?php
 $conn_id = ftp_connect($server);
 $login_result = ftp_login($conn_id, $user, $pass);

 if ((!$conn_id) || (!$login_result)) {
echo "Connection problem! ";
die;
 }
 else {
$list=Array();
$list=@ftp_nlist($conn_id, "dirName");
$i=0;

do{
?>
<OPTION value="<?php echo $list[$i]; ?>">
 <?php

echo $list[$i];
$i++;
}while($list[$i]);

 }

?>

</SELECT>
</form>

//JAVASCRIPT
<script language="JavaScript">
function FileContenu(n){
 var inputf ="";

inputf=n.Types.options[n.Types.selectedIndex].value;

if(inputf=="choisir"){
n.mesg.value = "";

}

else{

<?php

//conection ftp to read the file
$file="ftp://$user:$pass@$server/home/$user/????";;
$filehandle=fopen($file,"r");
if($filehandle){

while (!feof ($fp)) {
$buffer = fgets($fp, 4096);

}

fclose($filehandle);

?>

n.mesg.value = "<?php echo $buffer;?>";





}
}


//-->
</script>


______________________________________________________
Bote aux lettres - Caramail - http://www.caramail.com





----------------------------------------------------------------------------
----


> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to