Hello All,
I'm trying to display records in a table, that has a button at the end
of each row, that calls a JavaScript popup to confirm the delete.
I'm stuck and would appreciate any help anyone can offer.
Some of the code is attached.
Thanks!
Sterling
<head>
<script type="text/javascript">
<!--
function confirmation() {
var answer = confirm("Delete Record?")
// how can I pass the record ID from python to javascript?
// I tried something like ... recno = "{{=r.id}}"
recno = '48'
if (answer){
// delete the specified record number
alert("Deleting Record Number# " + recno )
window.location = "http://IP-ADDRESS:8000/appname/
controller/delete/" + recno;
}
else{
alert("The record was NOT deleted")
}
}
//-->
</script>
</head>
{{# tboffice.id tboffice.fdesc tboffice.fprice }}
<table>
{{ for r in recs: }}
{{ price = '%.2f' % r.fprice }}
{{ rec_id = '%04i ' % r.id }}
{{ d = r.fdesc }}
<tr>
<td> {{=rec_id}} </td> <td> {{=r.fdesc}} </td> <td align="right">
{{=price}} </td> <td> {{=LI(A("Delete", _href=URL(r=request ,
f="delete/"+str(rec_id) ))) }} </td> <td> <form> <input type="button"
onClick="confirmation()" value="Delete"> </form> </td>
</tr>
{{pass}}
</table>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---