I have a problem with javascript
.
Let's say I have javascript
function like this:
<script>
function show_popup(id) {
alert(id);
}
</script>
EDIT
On the other hand, I have an anchor which call that function:
<?php
...
$rs5 = $db->Execute("SELECT * FROM students");
foreach ($rs5 as $roww) {
echo "<tr $clr onMouseOver=this.bgColor='gold'; onMouseOut=this.$clr; >"
."<td>".$roww[name]." </td>"
."<td><a href='javascript:void(0);' title='Show' onClick='show_popup(".$roww[id].");'> SHOW </a></td>"
."</tr>";
}
...
?>
When I click that anchor, it'll show alert
which says whatever in show_popup
parameter, right?
Now, I have a problem that sometimes, the alert content and the parameter on onClick
did not equal (changed).
(Ex.: ... onClick='show_popup(547);' ...
, the alert shows: 987
)
UPDATED:
Here's a screenshot between alert
and the inspect element onClick
inline (the function name is detail_popup
which is the same as show_popup
above):
How can i fixed it?
Thank you so much for any answer.
As i can see in your console. HTML output is:
In onclick() function number is started with 00**** which denotes the number will convert to **Octal number thats why you are getting wrong output send number without 00 you will correct answer.