14/08/2008

Call: and Answer: are my new best friends!

Consider this problem. You have a web page in which you need to control the values that a user enters. If the value of an item is 'unusual' you want to ask the user if it is correct, and then - if they confirm it - set the value and tell them that you have done so.


There are several ways you could do this. You could have some javascript functions that check values and communicate via alert boxes, you could submit the page each time, track the state and branch accordingly, and then rebuild the original page if everything is kosher. And... you could do what Seaside does:


decrease
count = 0
ifTrue: [(self confirm: 'are you sure you want to do that?')
ifTrue: [self inform: 'go for it'.
count := -1000]]
ifFalse: [count := count - 1]

I have to admit, this is really impressive. And, once I figure out how to do this via ajax, it will be even more so. Andiamo!

No comments: