how can i use the variable from my php-sql to become the message for my javascript alert?
heres my code
<?php
$select = "SELECT * FROM post";
$result = mysql_query($select) or die("couldn't select table");
while ($rows = mysql_fetch_array($result))
{
echo"<input type='button' class=term onclick='return terms()' value=Terms >";
echo"<input type='hidden' value='$rows[terms]' id='term' name='term'>";
}
?>
<script language="JavaScript">
function terms()
{
var readers = document.getElementById("term");
alert(readers.value);
}
</script>
It works, the alert message displays. But I got the problem on displaying the right message for specific fetch of row. All got the same message (message from the first row).
I tried to use getElementByName but the alert doesn't pop-up, so i dont have to try making the input name="term[]" --------(into its array form)
Help please!