Posts

Showing posts from July, 2010

Read full agreement and then say "I agree"

Lot of sites show some licence text, make you accept it and only then you can proceed with the download/next pages. In order to make sure that you read these, some UI applications have a feature that the "I Agree" button is activated only when you have scrolled through the entire licence agreement. While this is easy to implement in WindowsUI, following a sample snippet how we implemented it in our web applications. <div style="HEIGHT: 150px; OVERFLOW: auto" onscroll="javascript:displayScroll(this);"> I Agree I cannot agree to this agreement.<br/>I Agree I cannot agree to this agreement.<br/> I Agree I cannot agree to this agreement.<br/>I Agree I cannot agree to this agreement.<br/> I Agree I cannot agree to this agreement.<br/>I Agree I cannot agree to this agreement.<br/> I Agree I cannot agree to this agreement.<br/>I Agree I cannot agree to this agreement.<br/> I Agree I cannot agree to this agreem...

Dirty workarouds: dirty page checking + AJAX

Dirty page checking is scenario when you have a form, user does some modifications and before hitting the save button, tries to leave the page. Enterprise web applications have a requirement to intimate the user that "there are unsaved details" and "do you really want to move away from this page". The idea of solution behind this is 1. use of window.beforeunload and 2. use of onchange to register the window.beforeunload. As setting window.beforeunload manually for each control can be timeconsuming, we need a generic solution which will work with minimal code changes. If you search for this on internet, you will find the following generic code: <script type="text/javascript"> function setDirty() { window.onbeforeunload = showNavigateAwayMessage; } function clearDirty() { window.onbeforeunload = ""; } function showNavigateAwayMessage() { return "There is some unsaved Data in this form." } function setControlChangeEvent() { if (typeo...

Combination of onblur event and .focus() can cause recusion errors

Image
We had a strange and irritating recusrsive popup problem in our web application during our last release. User scenario: We have a grid with a text box in each row for tax value. On page load, this is populated with default tax values: User can edit the tax amount in each textbox. Now, the requirement is that the user should not be able to set all the textboxes to zero. Further, when the user tries to do that, a message should be shown and the focus should go back to this textbox whose value was being set to zero. How we were doing this We were using onBlur event of textbox, check if all text boxes set to zero and set the focus back if yes. ..... checkAllTextsBlank(movedAwayFrom) { var allTextboxesZero = areAllTextboxesZero(); if(allTextboxesZero) { alert("You cannot set all taxes to zero"); movedAwayFrom.focus(); } Where areAllTextboxesZero used to iterate through each textbox and see if all have zero value. Problem in this approach Consider this scenario: We set the first te...