I have a view that create an invoice, at present i can only delete 1 item at a time from the invoice but what i want is to be able to delete all items from the invoice at the same time by clicking a link, below is my code.
*INVOICE CODE:* *<div id="pdf"><a href="javascript:genPDF()">Click to Download as PDF</a></div> <div id="invoicing"> <div id="letterHead"> <span class="letterHead invoice"> <img src="{{=URL('static', 'images/logoicon.png')}}" width="100px" height="100px"/> <span style="font-weight: bold;">COMPANY</span><br /> TELEPHONE: ............<br /> EM@IL: .............@gmail.com<br /> CELL: ............<br /> POSTAL-ADDRESS:..............<br /> </span> <span class="customerInv">Invoice No: ___________<br /> Contact: {{=invoice.proxy}}<br /> Company: {{=invoice.company}}<br /> Tel: {{=invoice.tel}}<br /> Postal Address: {{=invoice.postalAddress}} </span></div> <hr /><div><table><tr> <th>Order</th> <th>Quantity</th> <th>Order Price(VAT Exclusive)</th> <th>Amount</th></tr>{{for invoice in customer:}} <tr> <td>{{=invoice.client_order}}</td> <td>{{=invoice.quantity}}</td> <td>{{=MoneyFormat(invoice.beforeVat)}}</td> <td>{{=MoneyFormat(invoice.quantity*invoice.beforeVat)}}</td></tr> {{pass}} {{for price in pricing: try: vat=round(price.total*0.12, 2) totalPrice=price.total+vat except: redirect(URL('notInvoiced')) }} {{pass}} <tr> <td style="font-weight: bold; font-size: 14px; color: blue;" width: 29px;>Sub-Total:</td><td style="font-weight: bold; font-size: 14px; color: blue;" width: 29px>{{=MoneyFormat(price.total)}}</td><td style="font-weight: bold; font-size: 14px; color: black;" width: 29px;>(VAT EXCLUSIVE)</td> </tr> <tr> <td style="font-weight: bold; font-size: 14px; color: red;" width: 29px;>12% VAT: </td><td style="font-weight: bold; font-size: 14px; color: red;" width: 29px>{{=MoneyFormat(vat)}}</td> </tr> <tr> <td style="font-weight: bold; font-size: 14px; color: green;" width: 29px;>Total: </td><td style="font-weight: bold; font-size: 14px; color: green;" width: 29px>{{=MoneyFormat(totalPrice)}}</td><td style="font-weight: bold; font-size: 14px; color: black;" width: 29px;>(VAT INCLUSIVE)</td> </tr> {{pass}} {{pass}}</table> <br /> <div style="font-weight: bold;"> Client Sinature: ____________________<br /> {{=invoice.Booked_By.first_name}} {{=invoice.Booked_By.last_name}}<br /> Date & Time: {{=invoice.Booking_Date}}<br /> </div> <center><span style="font-weight: bold; font-style: italic;"> Thank you for your business!<br /> Company </span></center> </div></div><script> $('document').ready(function(){ $(".delete").click(function(){ return confirm('Are you sure you want to delete this this INVOICE?!'); }); });</script>#BY CLICKING THE LINK BELOW I WANT TO BE ABLE TO DELETE ALL THE INVOICE ITEMS AT ONCE<div id="delete"><a class="delete" href="{{=URL('deleteInvoice', args=invoice.id)}}">Delete Invoice</a></div><br /><div id="editor"></div><button onclick="topFunction()" id="myBtn" title="Go to top">TOP</button>* *INVOICE DELETING CONTROLLER* def deleteInvoice(): #THE .first() FUNCTION IN THE LINE BELOW ONLY ALLOWS ME TO DELETE ITEMS ONE AT A TIME * query = db(db.invoice.id==request.args(0, cast=int)).select().first() * remove = db(db.invoice.id==query).delete() if remove: redirect(URL('registeredClients')) return locals() The *.first()* function in the green highlighted line in the above controller only allows me to delete the invoice items one at a time, is there another function i can use that will allow me to delete them all at once? By deleteng the invoice items this will delete the entire invoice allowing the user to implement a new invoice. Please help! Mostwanted -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.