I have a php
page, a html button on it and there I should call a JS
function with a php variable. And I get the error
the variable is not defined
Here is the code:
<body>
<form class="form">
<?php
if(file_exists('megjelenitendo.txt')){
$mappak=array();
$mappakdb=0;
$megjelenitendo = fopen("megjelenitendo.txt", "r") or die("Unable to open file!");
while(!feof($megjelenitendo)) {
$mappak[$mappakdb]=fgets($megjelenitendo) ;
$mappakdb++;
}
fclose($megjelenitendo);
$j=0;
foreach(glob('*') as $filename){
for($i=0; $i<$mappakdb;++$i){
//echo $filename."==".$mappak[$i];echo "<br>";
if(strtoupper($filename)==strtoupper(trim($mappak[$i]))){
//echo '<button type="submit" id='.$i.' class="button" formaction='.$filename.' />'.$filename;//substr($filename, 3,strlen($filename));
echo '<button type="button" id='.$i.' class="button" OnClick=mappanyitas('.trim($mappak[$i]).')>'.trim($filename).'</button>';
echo '<br>';
}
else{}
}
}}
else{
echo "A mappa elemei:<br>";
}
?>
</form>
<script type="text/javascript">
function mappanyitas(filename){
alert(filename);
}
</script>
</body>