Reputation: 89
My function is something like this:
function delete(type, id){
if(id){
window.location.href = '/site/'+type+'/delete/'+id;
}
}
I'm calling it like this:
onclick="delete('position', <?php echo $key;?>)
Where in the function should I put the Confirm option?
Upvotes: 0
Views: 794
Reputation: 1960
try this:
function deleteIt(type, id)
{
if(id && confirm('Are you sure you want to delete?'))
{
window.location.href = '/site/'+type+'/delete/'+id;
}
}
Upvotes: 2
Reputation: 10824
function delete(type, id)
{
if(id && (confirm('Are you sure you want to delete?')))
{
window.location.href = '/site/'+type+'/delete/'+id;
}
}
Upvotes: 0