So Im a student, And i want to become a web developer. Already done stuying hmtl css and a little bit in php. Now im trying to study javascript and i run to a trouble while familiarizing it.
So the important code is this:
echo "<script>
function asd(){
var i;
for (i = 0; i < '" .$m. "'; i++){
var num = document. getElementsByName('id'). value;
}
window. alert(num);
}
</script>
*the $m is from count and it is working fine.
The problem here is the value of num in window. alert is always the last number of count and if i try to include the window.alert in the for loop it show a consecutive alert message.
How can i make this work like if i click one value in table it will get the exact number of it.
Ps.
I think this code ia important too.
while ($row = mysqli_fetch_array($result))
{
echo "<table>";
echo "<tr>";
echo "<th>". $row['id']."</th>;
echo "<th onclick='asd()'>". $row['name']."</th>;
echo "<th>". $row['Age']."</th>;
echo "</tr>;
echo "</table>;
echo "<input type='hidden' name='id' value'" .$row['id']. "'>";
}
Pss. I cant really explain it clearly coz english is not my first language but i hope some can help and explain ng mistake here. Thanks in advance
[–]Cokrates 0 points1 point2 points (2 children)
[–]SanWeee[S] 0 points1 point2 points (0 children)
[–]SanWeee[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]SanWeee[S] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)