• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Trigger Undo from Javascript?

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a way to trigger the undo that occurs when a user types Ctrl-Z (in IE, I don't know about other browsers) in a text box from Javascript?

Bert Evans
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
something like this I believe:

Eric
 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Eric,

After I test the "document.execCommand('undo', false, null)" method, I find it works well in text-oriented HTML elements when you want to roll back what a user has done. Now I am eager to know how to undo the user's operation using Javascript. For example, in a web page which is used for writing questions for a quiz, a user will do from scratch when he logged on and he might take the following steps:

1) Press a select element to choose the nubmer of answers for the first question.
2) Create a table on the fly whose rows are equal to the previous selected number plus 1.
3)Fill in the question and its answers.
4)Generate a "Next" button on the fly automatically when he is about to input the last answer.
5)Press the "Next" button to write the second question.

How can I afford a list A to let the user undo the above operation and a list B redo these operation step by step? In other words, how can I implement this functionality using Javascript just like what we do in Microsoft's Excel?

Thanks in advance!
Regards, Ailsa Cape
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would have to code the functionality yourself. Build an array/object that contains the steps and when they undo, you look at your array, find the elements that need to be removed.

The browser does not understand changes made to the UI via JavaScript.

Eric
 
Ailsa Cape
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Eric,

Thank you for your quick response! Can you introduce some material or web links which thoroughly discuss the subject to me?

Best Regars, Ailsa Cape
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic