Dsiplaying a confirmation message
Moderator: General Moderators
Dsiplaying a confirmation message
I have been asked to provide a confirmation message prior to a table commit. If the user confirms, the table update occurs, if not, they can alter their form edits. This request sounds simple enough, but I suspect it's not when working with a web app environment. Is there a simple way to handle this without the user losing their form edits upon cancel?
One thought I had was to never leave the form, and just change the visibility of the form objects in java script.
Do form objects have a visible property? Can I have three buttons, "Ok", "Cancel", "Do It" on the form, where only the "Do It" button is initially visible. Pressing "Do It" will execute java code to change the confirm message visibility, set the "Do It" visible prop to false, and "Ok", "Cancel" to true.
Is this even possible? Is there an easier way?
Any examples I can look through that deal with this?
Am I making it tougher than it really is?
Michael
One thought I had was to never leave the form, and just change the visibility of the form objects in java script.
Do form objects have a visible property? Can I have three buttons, "Ok", "Cancel", "Do It" on the form, where only the "Do It" button is initially visible. Pressing "Do It" will execute java code to change the confirm message visibility, set the "Do It" visible prop to false, and "Ok", "Cancel" to true.
Is this even possible? Is there an easier way?
Any examples I can look through that deal with this?
Am I making it tougher than it really is?
Michael
assuming you have a <form> submitting your data:
notice the onsubmit form attribute.
Code: Select all
<form action="something.php" method="POST" onsubmit='return confirm("Are you really really sure?");' >
<!-- form elements here -->
</form>
Thankyou. This is much easier/cleaner than what I ended up doing. Is there a way to make this a dynamic message?Weirdan wrote:assuming you have a <form> submitting your data:notice the onsubmit form attribute.Code: Select all
<form action="something.php" method="POST" onsubmit='return confirm("Are you really really sure?");' > <!-- form elements here --> </form>
I have a two line message that can have essentially 3 message types. Within these three types, there are more specific variations. I am storing the messages in a couple text boxes which I display when needing confirmation. Is there a way to output the message using the onsubmit contained in a form object?
Code: Select all
document.getElementById('txtConfirm').value = lcMessage ;
document.getElementById('txtConfirm1').value = lcSecondLine ;Michael
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
What happens if your users have disabled javascript? Or if they are using user agents that do not support javascript (PDA, Cell Phones, etc)? Have you given any consideration to server-side confirmations? One good point is that they are independent of the browser. Of course, one drawback is they require another trip to the server. But at least you know that the confirmation will always fire.
I find http://www.onlinetools.org/articles/uno ... pter1.html quite interesting. Basically, i don't have any javascript in my html markup but i attach it all when the script is loaded (actually, i attach when the document onload event occurs).
I think the saying "I know enough to be dangerous" applies. It's possible that they could have disabled javasripts. I doubt they would be using this section of the website using anything but desktop/laptops. This is a fairly small community of users who will be using this section of the website - e.g., members of an organization.Everah wrote:What happens if your users have disabled javascript? Or if they are using user agents that do not support javascript (PDA, Cell Phones, etc)? Have you given any consideration to server-side confirmations? One good point is that they are independent of the browser. Of course, one drawback is they require another trip to the server. But at least you know that the confirmation will always fire.
My original approach was to add a layer to the application, where upon submission, I would save their edits to a session array, and prompt them with a warning dialog. The methods responsible for displaying would use the values in the session array (if set), and they canceled, otherwise process them as normal. Avoiding that change, using the onsubmit event, is cleaner and wouldn't involve adding this layer to the 3 methods responsible for displaying/processing. When I started to post my original question, I was going to ask if the "road" I was headed down was a good road to "travel", but while writing thought of the alternate approach using client side confirmation.
Is there a way to use the onsubmit using server side code? Is there another way to do this without adding the layer? I like the idea of having the confirm dialog return true/false to the onsubmit. This is the way I normally would do things in a desktop application.
Thanks for your warning about javascript disabling.
Michael
I'll take a look at the link. I can use all the help - I figure I have about a 30 % understanding of the object model et. al.- maybe, that's overestimatedtimvw wrote:I find http://www.onlinetools.org/articles/uno ... pter1.html quite interesting. Basically, i don't have any javascript in my html markup but i attach it all when the script is loaded (actually, i attach when the document onload event occurs).
Thanks for the pointer,
Michael