JavaScript を使用してページに送信されたフォームから値を取得したいと考えています。これが私のJavaScript関数とフォームです。
<?php
echo"<html>";
echo"<script type='text/javascript'>";
echo"function submitform(){";
echo"document.getElementById('myform').submit();}";
echo"</script>";
echo"<form id='myform' action='comment.php' method='post'>";
echo"<tr>";
echo "<td><img src='photos/$file' alt='$file'><br></td>";
echo "<tr><td><a href=\"delete.php?id=".$file."\" onclick=\"return confirm('You want to delete .$file???');\">".$file."</td></tr>";
echo "<tr><td><a href=\"like.php?id=".$file."\">like</td></tr>";
echo "<tr><td>".$result."likes</td><tr>";
echo "<tr><td><a href=\"dislike.php?id=".$file."\">unlike</td></tr>";
echo "<tr><td>".$result1."unlikes</td><tr>";
echo"<tr><td colspan='2'>Your Comment: </td>";
$_SESSION['comment']=$file;
echo" <td colspan='5'><textarea name='comment' id='comment' rows='2' cols='25' ></textarea></td></tr>";
echo"<tr><td colspan='2'><a href='javascript: submitform()'>Comment</a></td></tr>";
//echo"<td><form name='up' action='delete.php' method='post' enctype='multipart/form-data></td>";
//echo"<td><a href='http://127.0.0.1/delete.php'><button name='button' type='submit' value='photos'>delete</button></a></td>";
//$_SESSION['comment']=$file;
echo"</form>";
echo"</tr>";
?>