You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Norris Shelton <no...@yahoo.com> on 2005/02/08 22:58:22 UTC

Problem with checkbox

I have a checkbox drawn by:
<html:checkbox property="recordTypebooking"
     onclick="javascript:${recordType.name}BoxDisplay();" />
${recordType.description} <br />


The form is defined as:
<form-bean name="searchNameForm"
type="org.apache.struts.validator.LazyValidatorForm" >
     ...
     <!-- default recordTypeBooking to booking -->
     <form-property name="recordTypebooking"
type="java.lang.Boolean" initial="true"/>
     ...
</form-bean>

The check box displays correct and even defaults.  If I uncheck
the box and submit, when it failes validation, it is still
checked.


=====

Norris Shelton
Software Engineer
Sun Certified Java 1.1 Programmer
Appriss, Inc.
ICQ# 26487421
AIM NorrisEShelton
YIM norrisshelton



		
__________________________________ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.com 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: OT: Problem with checkbox - now javascript problem

Posted by Norris Shelton <no...@yahoo.com>.
having a checkbox with the same name as a hidden field prevented
the value from being evaluated.   This was solved by putting the
script directly into the onclick method.

onclick=" if (this.checked == true) {
  
document.getElementById('${recordType.name}Box').style.display='block';
} else {
  
document.getElementById('${recordType.name}Box').style.display='none';
}"

This forced me to define a hidden area for all the properties,
but that was easier than investing more time.

--- Norris Shelton <no...@yahoo.com> wrote:

> Dang it.  This is not going to work for me.  I have a check
> box.
>  If the check box is checked, I have some javascript looking
> for
> the click event.  If the check box has a .checked = true.  I
> change div's display value to block, else to none.  So, you
> check the check box and some radio buttons show up, else they
> disappear.
> 
> If I put the hidden field, then the javascript returns an
> undefined value.  Any ideas on how to solve this.  Here is
> what
> the html looks like:
> 
> <input type="checkbox" name="recordTypebooking" value="true"
> checked="checked" onclick="javascript:bookingBoxDisplay();">
> Bookings <br />
> <input type="hidden" name="recordTypebooking" value="false">
>         
>             
> <script type="text/javascript" language="JavaScript">
> <!--
>    function bookingBoxDisplay(){
>       if (document.searchNameForm.recordTypebooking.checked) {
>        
> document.getElementById('bookingBox').style.display='block';
>       } else {
>        
> document.getElementById('bookingBox').style.display='none';
>       }
>    }
> // -->
> </script>
>                 
> <span id="bookingBox" class="leftPad15"
> style="display:block;">
>    <input type="radio" name="recordTypebookingValue"
> value="all"
> checked="checked"> All <br />
>    <input type="radio" name="recordTypebookingValue"
> value="incarcerated"> Incarcerated Only
> </span>
> 
snipped...

=====

Norris Shelton
Software Engineer
Sun Certified Java 1.1 Programmer
Appriss, Inc.
ICQ# 26487421
AIM NorrisEShelton
YIM norrisshelton



		
__________________________________ 
Do you Yahoo!? 
All your favorites on one personal page � Try My Yahoo!
http://my.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: OT: Problem with checkbox - now javascript problem

Posted by Norris Shelton <no...@yahoo.com>.
Dang it.  This is not going to work for me.  I have a check box.
 If the check box is checked, I have some javascript looking for
the click event.  If the check box has a .checked = true.  I
change div's display value to block, else to none.  So, you
check the check box and some radio buttons show up, else they
disappear.

If I put the hidden field, then the javascript returns an
undefined value.  Any ideas on how to solve this.  Here is what
the html looks like:

<input type="checkbox" name="recordTypebooking" value="true"
checked="checked" onclick="javascript:bookingBoxDisplay();">
Bookings <br />
<input type="hidden" name="recordTypebooking" value="false">
        
            
<script type="text/javascript" language="JavaScript">
<!--
   function bookingBoxDisplay(){
      if (document.searchNameForm.recordTypebooking.checked) {
       
document.getElementById('bookingBox').style.display='block';
      } else {
       
document.getElementById('bookingBox').style.display='none';
      }
   }
// -->
</script>
                
<span id="bookingBox" class="leftPad15" style="display:block;">
   <input type="radio" name="recordTypebookingValue" value="all"
checked="checked"> All <br />
   <input type="radio" name="recordTypebookingValue"
value="incarcerated"> Incarcerated Only
</span>

            
--- Norris Shelton <no...@yahoo.com> wrote:

> Now I see clearer what you were saying.  I found this in the
> java forums.
> 
>
http://forum.java.sun.com/thread.jspa?threadID=242031&messageID=2946045
> 
> It worked like a charm.
> 
> I wonder why the html:checkbox docs don't mention this.
> 
> Thanks for your help.
> 
> --- C�dric Levieux <jo...@gmail.com> wrote:
> 
> > Because when you uncheck a checkbox you don't send this
> field
> > and the
> > form process let the previous value in place
> > 
> > One of tips of mine is to put a hidden field with the same
> > name and to
> > see the field as an array : when it contains only one value
> > the
> > checkbox is unchecked, checked otherwise
> > 
> > Hope it will help,
> > 
> > Cedric
> > 
> > 
> > On Tue, 8 Feb 2005 13:58:22 -0800 (PST), Norris Shelton
> > <no...@yahoo.com> wrote:
> > > I have a checkbox drawn by:
> > > <html:checkbox property="recordTypebooking"
> > >     onclick="javascript:${recordType.name}BoxDisplay();"
> />
> > > ${recordType.description} <br />
> > > 
> > > The form is defined as:
> > > <form-bean name="searchNameForm"
> > > type="org.apache.struts.validator.LazyValidatorForm" >
> > >     ...
> > >     <!-- default recordTypeBooking to booking -->
> > >     <form-property name="recordTypebooking"
> > > type="java.lang.Boolean" initial="true"/>
> > >     ...
> > > </form-bean>
> > > 
> > > The check box displays correct and even defaults.  If I
> > uncheck
> > > the box and submit, when it failes validation, it is still
> > > checked.
> > > 
> > > =====
> > > 
> > > Norris Shelton
> > > Software Engineer
> > > Sun Certified Java 1.1 Programmer
> > > Appriss, Inc.
> > > ICQ# 26487421
> > > AIM NorrisEShelton
> > > YIM norrisshelton
> > > 
> > > __________________________________
> > > Do you Yahoo!?
> > > Meet the all-new My Yahoo! - Try it today!
> > > http://my.yahoo.com
> > > 
> > >
> >
>
---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail:
> user-help@struts.apache.org
> > > 
> > >
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> > 
> 
> 
> =====
> 
> Norris Shelton
> Software Engineer
> Sun Certified Java 1.1 Programmer
> Appriss, Inc.
> ICQ# 26487421
> AIM NorrisEShelton
> YIM norrisshelton
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection
> around 
> http://mail.yahoo.com 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


=====

Norris Shelton
Software Engineer
Sun Certified Java 1.1 Programmer
Appriss, Inc.
ICQ# 26487421
AIM NorrisEShelton
YIM norrisshelton


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem with checkbox

Posted by Norris Shelton <no...@yahoo.com>.
Now I see clearer what you were saying.  I found this in the
java forums.

http://forum.java.sun.com/thread.jspa?threadID=242031&messageID=2946045

It worked like a charm.

I wonder why the html:checkbox docs don't mention this.

Thanks for your help.

--- C�dric Levieux <jo...@gmail.com> wrote:

> Because when you uncheck a checkbox you don't send this field
> and the
> form process let the previous value in place
> 
> One of tips of mine is to put a hidden field with the same
> name and to
> see the field as an array : when it contains only one value
> the
> checkbox is unchecked, checked otherwise
> 
> Hope it will help,
> 
> Cedric
> 
> 
> On Tue, 8 Feb 2005 13:58:22 -0800 (PST), Norris Shelton
> <no...@yahoo.com> wrote:
> > I have a checkbox drawn by:
> > <html:checkbox property="recordTypebooking"
> >     onclick="javascript:${recordType.name}BoxDisplay();" />
> > ${recordType.description} <br />
> > 
> > The form is defined as:
> > <form-bean name="searchNameForm"
> > type="org.apache.struts.validator.LazyValidatorForm" >
> >     ...
> >     <!-- default recordTypeBooking to booking -->
> >     <form-property name="recordTypebooking"
> > type="java.lang.Boolean" initial="true"/>
> >     ...
> > </form-bean>
> > 
> > The check box displays correct and even defaults.  If I
> uncheck
> > the box and submit, when it failes validation, it is still
> > checked.
> > 
> > =====
> > 
> > Norris Shelton
> > Software Engineer
> > Sun Certified Java 1.1 Programmer
> > Appriss, Inc.
> > ICQ# 26487421
> > AIM NorrisEShelton
> > YIM norrisshelton
> > 
> > __________________________________
> > Do you Yahoo!?
> > Meet the all-new My Yahoo! - Try it today!
> > http://my.yahoo.com
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> >
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


=====

Norris Shelton
Software Engineer
Sun Certified Java 1.1 Programmer
Appriss, Inc.
ICQ# 26487421
AIM NorrisEShelton
YIM norrisshelton


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem with checkbox

Posted by Cédric Levieux <jo...@gmail.com>.
Because when you uncheck a checkbox you don't send this field and the
form process let the previous value in place

One of tips of mine is to put a hidden field with the same name and to
see the field as an array : when it contains only one value the
checkbox is unchecked, checked otherwise

Hope it will help,

Cedric


On Tue, 8 Feb 2005 13:58:22 -0800 (PST), Norris Shelton
<no...@yahoo.com> wrote:
> I have a checkbox drawn by:
> <html:checkbox property="recordTypebooking"
>     onclick="javascript:${recordType.name}BoxDisplay();" />
> ${recordType.description} <br />
> 
> The form is defined as:
> <form-bean name="searchNameForm"
> type="org.apache.struts.validator.LazyValidatorForm" >
>     ...
>     <!-- default recordTypeBooking to booking -->
>     <form-property name="recordTypebooking"
> type="java.lang.Boolean" initial="true"/>
>     ...
> </form-bean>
> 
> The check box displays correct and even defaults.  If I uncheck
> the box and submit, when it failes validation, it is still
> checked.
> 
> =====
> 
> Norris Shelton
> Software Engineer
> Sun Certified Java 1.1 Programmer
> Appriss, Inc.
> ICQ# 26487421
> AIM NorrisEShelton
> YIM norrisshelton
> 
> __________________________________
> Do you Yahoo!?
> Meet the all-new My Yahoo! - Try it today!
> http://my.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org