Win a copy of Fixing your Scrum this week in the Agile forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

multibox disabled but checked

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am displaying a list of checkboxes where some are selected by default and the user cannot uncheck them..So I set the disabled= true attribute for those checkboxes.
When I do a form submit, the values of the disabled checkboxes are not sent
even though they are checked...

How to gracefully solve this ?

Thanks
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am no expert in Struts, but I thought this was an interesting question. When a multibox is sent, the clients browser recieves a list of checkboxes like
<input type="checkbox" name="chkBox" value="white" checked="true" disabled="true">
<input type="checkbox" name="chkBox" value="black" checked="true" disabled="true">
<input type="checkbox" name="chkBox" value="blue" checked="false">
<input type="checkbox" name="chkBox" value="green" checked="false">

The values of the checked but disabled checkboxes are available to javascript. So, couldn't you cycle through the checkboxes with chkBox[i] and rebuild the URL before the form is submitted? It may not be the fanciest solution, but I think it should work. Maybe someone more experienced in Struts could tell us if this is not a good idea?

Thanks,
Eric
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unfortunately, disabled inputs don't submit a value. The method suggested by Eric will work. Here are a couple more possible workarounds:

For each disabled checkbox, create a <html:hidden> field with the same property name. The hidden control will be submitted.

Another possibility would be to use javaScript to re-enable the checkboxes just before the form is submitted.
 
Janhvi Malhotra
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Guys,

the work around I have is, since the server already knows the defaultchecked checkboxes, I add them to what the user selected..
 
Happily living in the valley of the dried frogs with a few tiny ads.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic