Tuesday, 17 September 2013

Javascript: Need to proceed to another page

Javascript: Need to proceed to another page

I'm using Javascript for deleting a record. But my problem is, when I
click the image button its not redirecting to the page I want instead it
will remain on the page...
Here's my code:
echo "<button type='submit' name='deletePlaylist[]' value='" .
$row['id']."' onClick='myFunction()' style='border: 0; background:
transparent; cursor: pointer;'><img src='image/delete.png' /></button> ";
I'm using the button because I'm using an image if I used the input its
not working... So I decided to use button
Here's my code in my javascript:
function myFunction()
{
var Xcancel;
var Rokay=confirm("Are you sure you want to delete?");
if (Rokay==true)
{
window.location = 'delete.php';
}
else
{
Xcancel="You pressed Cancel!";
}
}
</script>
I already tried the window.navigate("delete.php"); or the
window.location.href='delete.php' also not working...
The confirmation message is displaying already but my main problem its not
going to the delete.php where in that form is my deleting function...
NOTE:
The button is under of the <form name='form' method='post' action="">, the
delete.php is in the same folder... Before there is no confirmation
message and its going to the delete.php but now I tried to insert a
confirmation message then its not going to the delete.php
Thank you in advance,!

No comments:

Post a Comment