Reputation: 1534
I'm having an issue where i populate a button with an onclick, i see that in the HTML once its populated (after the document is first loaded) the onclick is there, but it wont trigger the function, heres the PHP code:
while($row = sqlsrv_fetch_array($result))
{
echo('<div class="row">
<div class="col"><span>Company Name: ' . $row['CompanyName'] . '</span></div>
<div class="col"><span>Telephone: ' . $row['CustomerNumber'] . '</span></div>
<div class="col"><span>Access Code: ' . $row['AccessCode'] . '</span></div>
<div class="col"><span>Active: ' . $row['Active'] . '</span></div>
<input type="button" value="Delete" onClick="javascript:delete(this);"></input></div><br />');
The delete function is on the same page as the populated button (function delete(e){}), any ideas why it wouldn't trigger?
Note there are no JS errors and javascript is enabled (can call a function directly from the browser)
EDIT:
Heres 1 line from the HTML output:
<br>
<div class="row">
<div class="col">
<span>Company Name: TBC</span>
</div>
<div class="col">
<span>Telephone: 354</span>
</div>
<div class="col">
<span>Access Code: </span>
</div>
<div class="col">
<span>Active: </span>
</div>
<input type="button" onclick="delete(this);" value="Delete">
</div>
Upvotes: 2
Views: 266
Reputation: 13145
delete()
is a reserved word in javascript, try changing the function name to deleteIt()
or something else instead.
Upvotes: 0