0

I'm doing a deleting function for a webpage which basically read input from user and compare it to the data from database and then delete. The code is already running perfectly. Just lack of confirm deletion popup. I've tried multiple method to put it and some of the error is regarding the 'GET' and 'POST' method. I dont want to change anything on the route because the function is already working properly. Below is some part of code.

<button>
  <a href="delete">Back</a>
</button>
&emsp;&emsp;
<button>
  <a href="{{URL::to('deleted/'.$d->domain_label.'/'.$d->domain_extension)}}">Delete</a>
</button>

And route:

Route::get('/servicedetails','ServiceDetailsController@showservicedetails');
Route::get('/delete','ManageController@delete');
Route::post('/delete2','ManageController@delete2');
Route::get('deleted/{domain_name}/{ext}','ManageController@deleteConfirm');

I want to put the popup on the onClick button and then run the function deleteConfirm().

Hope anybody can help.

Fadhil Adzfar
  • 77
  • 1
  • 8
  • sir you don't need to use **a** and **button** both of this. – Jayanta Mar 29 '17 at 06:44
  • 2
    http://stackoverflow.com/questions/10462839/javascript-confirmation-dialog-on-href-link – Pawan Mar 29 '17 at 06:45
  • 1) Don't put `a` elements inside `button` - that's invalid. Use one or the other. 2) Attach a click handler to the element you end up using, and then use a `confirm()` call to ask the user to confirm the action – Rory McCrossan Mar 29 '17 at 06:45

1 Answers1

1

You can use confirm() function of jQuery to get confirmation:

Try this:

<a href="{{URL::to('deleted/'.$d->domain_label.'/'.$d->domain_extension)}}" onclick="return confirm(' you want to delete?');">Delete</a>
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Dhara Parmar
  • 8,021
  • 1
  • 16
  • 27