How To Use Javascript Alert So That User Can Choose
I am trying to add an alert box so that the user can choose either Yes or No or Ok and Cancel, but it is not working correctly. It is my first time I am trying to do this. I am usi
Solution 1:
First I would try changing this:
Response.Write("var where_to= confirm: (\"Are You sure?\")");
to this:
Response.Write("var where_to= confirm(\"Are You sure?\")");
(The method is confirm()
and not confirm:()
)
Solution 2:
As already mentioned, you had an extra colon in your code. However, there is no need for the lengthy if/then logic, as the confirm
javascript method returns a boolean. Your code can be condensed to 3 lines:
Response.Write("<script>");
Response.Write("function onsub() { return confirm(\"are you sure?\"); }");
Response.Write("</script>");
Solution 3:
modify this line of code-> Response.Write("var where_to= confirm: (\"Are You sure?\")"); try this->Response.Write("var where_to= confirm ("Are You sure?")");
Solution 4:
method confirm() is correct but the string inside should be within double quotes that is confirm("Are You Sure?");
Solution 5:
Use confirm()
function.
privatevoidAlertWithOption()
{
Response.Write("<script language='javascript'>");
Response.Write("function onsub() ");
Response.Write("{ ");
Response.Write("return confirm(\"Are you sure?\")");
Response.Write("} ");
Response.Write("</script>");
}
I think you are doing mistake in the syntax of the confirm()
Post a Comment for "How To Use Javascript Alert So That User Can Choose"