Hi, I can get the confirmation script redirected to a page I want with the script bellow, but the variables I want to carry over do not pass. How do I solve this problem? <script type="text/javascript"> <!-- function confirmation() { var answer = confirm("Are you sure you want to delete the item?"); if (answer){ alert("Removing the item!"); window.location = "delete.php"; return true; } else { alert("Some items worth keeping!"); return false; } } //--> </script> <form method='post'> <input type='hidden' name='id' value='<?php echo $row['id']; ?>' /> <input type='hidden' name='name' value='<?php echo $row['name']; ?>' /> <input type='image' src='images/delete.png' onclick='confirmation(); return false' title='delete item' /> </form> Code (markup): Thanks so much
Never mind, I can achieve what I want with the get method following this tutorial: http://jamesowers.co.uk/javascript/303/javascript-confirm-box/ But why it takes much longer time to process the script with fewer line of codes? I'm still sticking with the post method though.
I get it done with the post method. For those who struggle with this, use the onsubmit event to handle it.
I can't see any variable passed to caling script. You need to pass the variable while calling function itself. Let me know which variable exactly you wanted to pass, i can help you to write code for the same. Sheetal