I want to make an alert using JavaScript. This is an example I have made bls.hol.es.
When I click first name will display an alert containing the first name. But it displays an alert containing the second name.
This is my code:
<?php
$arrayname=array('iqbal', 'rezza');
$arrayaddress=array('teloyo', 'karang rejo');
for ($x = 0; $x <= 1; $x++)
{
$name=$arrayname[$x];
$address=$arrayaddress[$x]; // indent consistently!!
?>
<script>
function call()
{
var nik = "<?php echo $name ?>"; // semicolons not needed in the embedded PHP code
var addres = "<?php echo $address ?>"; // indent consistently!!
alert(nik+address);
}
</script>
<a href="javascript:call();"><?php echo $name ?></a>
<?php
} ?>
Whether this can be done my way?
What is wrong in my code?
<a></a>. An inline alert will be just fine -- no bloat.