Hello all. ^__^
I am trying to create a form that will allow a user to delete one of many records on a table, which displays the data dynamically. I'd like to have a pop up window confirm that the user does indeed wish to delete the record, but I'm having trouble with the javascript function I wrote. When I DO NOT include any variables in my submit button, the function works fine, but when I do, I receive an error saying the variable is undefined. Here is my function:
Here is the code that DOES work, but isn't what I need:Code:<script language="javascript" type="text/javascript"> function ask(productID) { var answer = confirm("Are you sure you wish to remove this product?"); if (answer) window.location.href="removeProduct.php?id=" + productID; } </script>
This is what I need to have, but I receive an error (variable undefined) in doing so (where $row["id"] is generated dynamically with PHP):Code:<input type='button' value='Remove' onClick='ask();'>
I've been pouring over the internet for hours trying to find a solution but have been unable to find one. Any help is much appreciated! =DCode:<input type='button' value='Remove' onClick='ask(" . $row["id"] . ");'>



Reply With Quote
Bookmarks