Here’s my PHP code –
for ($i=1;$i<=10;$i++)
{
$numbers .= $i."\n";
}
echo "<input type='button' onclick=ShowNumbers('$numbers') value='Show Numbers'>";
And my Javascript code –
function ShowNumbers(numbers)
{
alert("Numbers:: "+numbers);
}
But when I click on the button Show Numbers, nothing happens. Whats going wrong ?
When in FireBug I check the button element it shows –
<input type="button" value="Show Numbers" ');="" 10="" 9="" 8="" 7="" 6="" 5="" 4="" 3="" 2="" onclick="ShowNumbers('1">
may be thats where the problem lies. How do I get it in right format?
The issue is in the way you format the parameters. If you look at the page source in the browser, then you’ll see the line breaks inside the parameters. If you want to have the message box display all the numbers, you can try doing this: