• 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

disable checked checkbox

 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to disable a checkbox that is checked. When the form is submitted,
the value of "checked" is not passed to the server. How should I
create a disabled "checked checkbox"?
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A disbaled element is not passed back to the server. They only thing you can do is use a hidden form element to pass the checked value or use Javascript to enable the text box. Dependence on JavaScript is not a good thing.

Eric
 
Glen Cai
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried hidden field with the same name, but it did not work.
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Couple things:
1. Hidden element vor disabled checkbox always works - you did something wrong. Basically

equals to


2. From security point of view (not sure, if that matters in your particular case) user is able to change/remove this element using scriplets, so there is a possibility of getting wrong value for that "disabled" element.
I would suggest you to keep a state somewhere and not relay on what you get from client.

3. There are couple other ways of doing the same thing, for example:
a) define checkbox as read only and use CSS to make it look like it disabled
b) define is as normal or readonly and "hidden"
c) dynamically add a hidden input or a checkbox to a form uppon submission
 
reply
    Bookmark Topic Watch Topic
  • New Topic