Re: onsubmit checkbox submission

Patrick Middleton <[email protected]>
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
On 31 Jan 2006, at 16:17, John Pollard wrote:

> I would like to update a WO page when a check box is ticked/unticked.
>
> I have placed a WOCheckBox within a WOForm.
>
> The WOCheckBox has onclick="this.form.submit()" and checked set to  
> myVar
> and the WOForm has action set to a callback method myCB
>
> What I see is that setMyVar is only called when the check box is  
> ticked, but not when it is unticked.
>
> The myCB for the form is called for both ticks and unticks, but  
> then this isn't passed the state of the check box
>
> I can add some convoluted logic to work out the fact that the user  
> has unticked (the fact that myCB is called without setMyVar having  
> been called in the same cycle), but there must be a better solution?
>
> Thanks
> John

http://www.blooberry.com/indexdot/html/tagpages/i/inputcheck.htm

"CHECKBOX is a TYPE attribute value to the INPUT element for FORMs.  
It  indicates a form field used for a boolean choice, or for  
attributes that  can take multiple values at the same time. The  
default state for a  checkbox is OFF. Only checkboxes that are in a  
checked state should be  submitted to the form processing script."

The cheat I'd use in this situation is an <INPUT TYPE=HIDDEN>, which  
gets tweaked by a javascript onChange handler attached to the <INPUT  
TYPE=CHECKBOX>.

Although having reviewed the discussion of WOcheckBox's bindings at  
http://developer.apple.com/documentation/WebObjects/Reference/ 
DynamicElements/WOCheckBox/chapter_7_section_3.html , I don't see why  
your logic needs to be convoluted if you shadow 'myVar' with an ivar  
'myVarChecked'.

-- Patrick
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.