javascript - How do I refresh a HTML table after editing it? -


i making simple system records bookings, editable other 'booking number' , 'price' sections static. booking number pre-defined , price variable dependent on value of 'number of seats chosen' column. 'price' column appears undefined when open .html file, , want refresh code after 'number of seats chosen' has been edited accordingly. price multiplies pre-defined , static, mean when number of seats chosen has been defined, multiplied 5. here code:

<script type="text/javascript"> var seatvar = document.getelementsbyclassname("seatchosen"); var pricepay = seatvar * 5 </script>  <script type="text/javascript"> function refreshtable () {             var table = document.getelementbyid ("bookingtable");             table.refresh ();         } </script>  <table class="editabletable" id="bookingtable" border="1"> <tr><th>booking number</th> <th>name</th> <th>number of seats chosen</th> <th>seats chosen</th> <th>price</th> </tr> <tr><td>1</td> <td><div contenteditable></div></td> <td class="seatchosen"><div contenteditable></div></td> <td><div contenteditable></div></td> <td><script type="text/javascript">document.write(pricepay);</script></td></tr> </table>  <p>price per seat: £5</p> <button onclick="refreshtable()">refresh table</button> 

the table shows 1 row, though there twenty follow same code. included headers too. don't understand why not refreshing after have edited value of number of seats chosen.

try code,

give id in place of success function.

js

$('.editabletable').click(function () {     $.ajax({         url: $(this).data("url"),         type: 'get',         cache: false,         success: function (result) {             $('#your_id').html(result);         }     });     return false; }); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -