Search code examples
htmlformspopupsubmit

Creating "are you sure?" popup window by using html only


Assume I have a html from, and it contain some submit type. I want to create a "are you sure" popup window that will appear when user click submit button. My question is that is there any way to create it by using "only" html, not using javascript or any other?


Solution

  • HTML only is possible, but not without a postback

    Scenario that could work without javascript:

    1. You have your form with submit button
    2. User clicks (and submits) the form
    3. You display another form with are you sure? form (that contains Yes and No buttons as well as hidden fields of the first form that will make it possible to do the action required on the original data
    4. functionality that executes the action and goes back to whatever required.

    This would be completely Javascript free, but it would require several postbacks.

    This kind of thing is usually done on the client with a Javascript confirm() function (here's a simple example) or lately with a more user friendly modal dialog provided by many different client libraries or their plugins.

    When to choose the script free version?

    If you know your clients are going to be very basic ones (ie. vast majority of your users will access your application using clients like Opera Mini that's not able to run scripts at all). But in all other cases it's much better to do this using Javascript. It will be faster, easier to develop and much more user friendly. Not to mention that it will put less strain on your server as well since certain parts will execute on the client without the need of any server processing.