I have a page where administrators can manage user accounts. This is done by clicking on an edit link next to the user’s name on the main page (admin/usermanage/) which takes the administrator to the edit page for that user ID (admin/usermanage/?edit=x (where X is the user ID)).
On this page, there is a delete button which takes the user back to the main page that lists all the accounts.
function deleteaccount_confirmation() {
var answer = confirm("Are you sure you want to delete this account?")
if (answer){
window.location = "../usermanage/index.php";
}
}
This doesnt work though. The user stays on the same page with the URL unchanged (admin/usernamage/?edit=x)
Any possible solutions?
Heres what I’ve done to fix it.
Rather than using javascript to move around pages, I’ve made a HTML form do it.
There is also no more GET variables in play anymore. The edit variable has been moved to POST.
Enough of my rambling, heres the code!
This part sits anywhere in the page.
This is the code for the button. It’s location in the page is respective to where the button is displayed but otherwise didn’t matter if it was in a form or not.
and lastly but not least the Javascript
What the javascript does is simply triggers the submition of the form using jQuery. The javascript is assigned to any button which is why it doesn’t need to be in the form. The form contains the data as a hidden variable which is triggered by the javascript.
Hope this helps everyone else!