• 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

Edit vs Read Only

 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a page with a bunch of fields displayed. I'd like to let the user click an "edit this page" button and turn the values into inputs. Ideally all my layout stays the same so the page doesn't jump or change size when changing modes.

I first tried to use input fields all the time but make them look like normal HTML in read-only mode. I found I could style disabled inputs with no border and with transparent background so they don't look like inputs, but IE doesn't let me set the font to black. (FireFox does)

My next two thoughts are to build plain either plain text or input fields based on mode in my JSP or to build two pages that happen to look an awful lot alike. One will probably be hard to read, the other will be duplicate maintenance. Ick and ick.

Any other better ideas? Is it time to learn or write a taglib?
[ August 28, 2007: Message edited by: Stan James ]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you try using readOnly instead of disabled?

Eric
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
D'oh! Never heard of it before! Thanks, I'll see if this does what I need in FireFox & IE.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One difference between disabled and readonly that you might want to keep in mind. Disabled fields are not posted with the rest of the form. It's as if they're not there.
Readonly, fields are posted with the form but the user can't change anything in them.
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That part doesn't bother me ... I'll hide the submit button when I go readonly. They are still tab stops, which is rather interesting but might be a little unusual.

It only took me the afternoon to get this working in IE and FireFox:

I still feel like a clumsy putz on client side code, but I'm having fun and getting ocasional results. My CSS classes make readonly look just like normal text and add a little padding so it doesn't jump up and down when I toggle.

I'm trying a "Joel on Software" idea he called "big ugly text boxes", switching to Courier mono-font for data entry. My eyes are not good enough to edit words like "Illinois" in verdana any more ... the Is and ls run together.
[ August 28, 2007: Message edited by: Stan James ]
 
I love a good mentalist. And so does this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic