On Thu, 2009-01-15 at 20:28 +0100, Luca Graf wrote:
> Hello together,
> 
> I got an problem with input components like <h:selectBooleanCheckbox> when i 
> use the attribute disabled=true. My scenario is that i have two checkboxes. 
> The second is initially set to disabled=true. Now the user should only get 
> access to the second if he changed the value of the first before. 
> 
> My approach was, if the user changed the value of checkbox1 then i set the 
> attribute of checkbox2 via javascript to disabled=false.
> 
> Example:
> <h:selectBooleanCheckbox id="checkbox1" onchange="var 
> element=document.getElementById('checkbox2'); if(element.disabled) 
> element.disabled = false; else element.disabled = true;">
> 
> <h:selectBooleanCheckbox id="checkbox2" disabled="false"/>
> 
> On the first it looks good, after the user has changed the value of the first 
> checkbox, the second is now accessible via html.
> But it looks that the value is doesn't send in the request to the server, 
> like the normal behavior for an input element with disabled=true.
> 
> It is not enough to set disabled=false in HTML to get the value of checkbox2 
> to the server?

Use "readonly" instead of "disabled". They appear the same to the user, but 
browsers send the state of "readonly" HTML elements back to the server on 
submit. Browsers ignore "disabled" HTML elements on submit, which is causing 
the problem.

Regards,
Simon

Reply via email to