This week I really got down to working on the website project for class. I spent hours on the cataloging interface page and created many text boxes for the advanced search features. Nick and I had decided that anything that was beyond the scope of the class would just be represented with an image rather than functional code, but I can't help it... I had working text boxes and I wanted to add the feature Nick and I planned on in the mockups -- dynamic default text that disappears when the user clicks on the box, and reappears if the user leaves the box without entering anything. It was relatively easy to find a tutorial that would walk me through the steps of creating my own code of having the text disappear on focus, but I couldn't get the text to reappear when the user left the box empty and clicked outside the box (or in another box).
This whole week I turned over the problem in my head, doing research on my lunch break. I would go to bed at night, and I couldn't stop thinking about html -- my wife even made up an html-related lullaby to try to keep my head from exploding.
Then I stumbled upon the onblur attribute of the input element, and I knew I'd found the mate the the onfocus attribute that I'd already used to clear the default text from the box. Over several hours last night, I tweaked my guesses at the code until it worked -- effectively by reversing the code for the onfocus event. Here's the working box.
This whole week, devoted to getting text to disappear and reappear in a box, gave me a new respect for web developers and how complicated it is the code all the fancy tricks that I take for granted as a web user. All that little stuff that creates a positive user experience is a lot of time and effort!
Very nice! I admire your skill and persistence. Best partner ever!
ReplyDeleteStumble on is often my best way of finding answers, too. Glad you got the disappearing text in your box to reappear with javascript.
ReplyDelete