Dynamic javascript assign
need to run a javascript on a button click. but the button is generated using a javascript as well
by Viraj Gamage
HTML
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="frmTable">
<form role="form" action="#">
<label>Number:</label>
<input type="text" id="noOfBlocks" onchange="getBlocks()">
<br/><br/><br/>
<div id="results" >
<!-- table get printed here -->
</div>
</form>
</div>
JavaScript
function getBlocks() {
var _html = '<table class="table table-bordered table-striped">';
var no, count
_html += '<tr>';
_html += '<th>Block No</th>';
_html += '<th>Lot No</th>';
_html += '<th>Extent</th>';
_html += '<th>Land Value</th>';
_html += '<th>On Booking Amount</th>';
_html += '<th>1/4th Duration(Weeks)</th>';
_html += '<th>Int Free Months</th>';
_html += '<th>Payble Duration</th>';
_html += '<th>Commission</th>';
_html += '<th>Other</th>';
_html += '<th>Plan copy Charges</th>';
_html += '<th>/</th>';
_html += '</tr>';
for (i = 1; i <= $('#noOfBlocks').val(); i++) {
_html += '<tr id="row' + i + '">';
_html += '<td><input type="text" size="10" id="blockNo' + i + '" value="' + i + '"></td>';
_html += '<td><input type="text" size="10" id="lotNo' + i + '" ></td>';
_html += '<td><input type="text" size="10" id="extent' + i + '"></td>';
_html += '<td><input type="text" id="land_value' + i + '"></td>';
_html += '<td><input type="text" size="10" id="onbookingamount' + i + '"></td>';
_html += '<td><input type="text" size="10" value="2" id="onefourthduration' + i + '"></td>';
_html += '<td><input type="text" size="10" value="8" id="intfreemonth' + i + '"></td>';
_html += '<td><input type="text" size="10" id="paybleduration' + i + '"></td>';
_html += '<td><input type="text" size="10" id="commission' + i + '"></td>';
_html += '<td><input type="text" size ="10" id="other' + i + '"></td>';
_html += '<td><input type="text" size="10" value="1500.00"...