You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by dnz <de...@gmail.com> on 2004/11/24 14:46:22 UTC
Setting checkboxes on/off from Javascript
Hi all.
I have a struts form bean to populate data on my JSP page which works
perfectly fine. I use a boolean attribute in my form bean to set the
checkbox control (at page load time) based on the boolean value. I'm
using the <html:checkbox .... struts tag for the checkbox controls.
The problem I'm having is .... when my javascript is triggered by
some event (onclick, etc.), the script is unable to uncheck (at
runtime) the already checked checkboxes. The script is able to set
the true/false value to the form bean its just not showing it on my
JSP page. If I use standard HTML (no JSP / Struts tags) my javascript
works fine.
My javascript goes like this...
code:
--------------------------------------------------------------------------------
document.getElementById("somecheckbox").value = false;
// i've also tried this:
document.getElementById("somecheckbox").checked = false;
--------------------------------------------------------------------------------
Any help would be appreciated.
--
dnz
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Setting checkboxes on/off from Javascript
Posted by dnz <de...@gmail.com>.
I lied....please disregard.
Thanks a bunch Andrew!!
On Wed, 24 Nov 2004 10:15:22 -0600, dnz <de...@gmail.com> wrote:
> Thank you for your reply.
>
> I tried your suggestion but still couldn't get to work.
>
> .... there's something else. I do get an object back but I think (its
> wierd)...the object I get is of type "hidden" (you know, the '<input
> type=hidden' thing), but there's nowhere in my JSP that I code
> 'hidden'. What is going on?
>
>
>
>
> On Wed, 24 Nov 2004 22:09:29 +0800, Andrew Hill
> <an...@gridnode.com> wrote:
> > hmm how about:
> >
> > document.forms[0].elements['somecheckbox'].checked = false;
> >
> > any luck with that?
> >
> > The value property is whats submitted when you submit, so its the
> > checked property your after, but Id have thought that your
> > document.getElementById("somecheckbox") should work? Maybe it needs an
> > explicit id attribute in the tag? (use the styleId attribute of the
> > struts tag if you need to set it)
> >
> >
> >
> > dnz wrote:
> >
> > > Hi all.
> > >
> > > I have a struts form bean to populate data on my JSP page which works
> > > perfectly fine. I use a boolean attribute in my form bean to set the
> > > checkbox control (at page load time) based on the boolean value. I'm
> > > using the <html:checkbox .... struts tag for the checkbox controls.
> > >
> > > The problem I'm having is .... when my javascript is triggered by
> > > some event (onclick, etc.), the script is unable to uncheck (at
> > > runtime) the already checked checkboxes. The script is able to set
> > > the true/false value to the form bean its just not showing it on my
> > > JSP page. If I use standard HTML (no JSP / Struts tags) my javascript
> > > works fine.
> > >
> > >
> > > My javascript goes like this...
> > >
> > >
> > > code:
> > > --------------------------------------------------------------------------------
> > >
> > > document.getElementById("somecheckbox").value = false;
> > >
> > > // i've also tried this:
> > >
> > > document.getElementById("somecheckbox").checked = false;
> > >
> > > --------------------------------------------------------------------------------
> > >
> > > Any help would be appreciated.
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
> --
> dnz
>
--
dnz
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Setting checkboxes on/off from Javascript
Posted by dnz <de...@gmail.com>.
Thank you for your reply.
I tried your suggestion but still couldn't get to work.
.... there's something else. I do get an object back but I think (its
wierd)...the object I get is of type "hidden" (you know, the '<input
type=hidden' thing), but there's nowhere in my JSP that I code
'hidden'. What is going on?
On Wed, 24 Nov 2004 22:09:29 +0800, Andrew Hill
<an...@gridnode.com> wrote:
> hmm how about:
>
> document.forms[0].elements['somecheckbox'].checked = false;
>
> any luck with that?
>
> The value property is whats submitted when you submit, so its the
> checked property your after, but Id have thought that your
> document.getElementById("somecheckbox") should work? Maybe it needs an
> explicit id attribute in the tag? (use the styleId attribute of the
> struts tag if you need to set it)
>
>
>
> dnz wrote:
>
> > Hi all.
> >
> > I have a struts form bean to populate data on my JSP page which works
> > perfectly fine. I use a boolean attribute in my form bean to set the
> > checkbox control (at page load time) based on the boolean value. I'm
> > using the <html:checkbox .... struts tag for the checkbox controls.
> >
> > The problem I'm having is .... when my javascript is triggered by
> > some event (onclick, etc.), the script is unable to uncheck (at
> > runtime) the already checked checkboxes. The script is able to set
> > the true/false value to the form bean its just not showing it on my
> > JSP page. If I use standard HTML (no JSP / Struts tags) my javascript
> > works fine.
> >
> >
> > My javascript goes like this...
> >
> >
> > code:
> > --------------------------------------------------------------------------------
> >
> > document.getElementById("somecheckbox").value = false;
> >
> > // i've also tried this:
> >
> > document.getElementById("somecheckbox").checked = false;
> >
> > --------------------------------------------------------------------------------
> >
> > Any help would be appreciated.
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
dnz
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Setting checkboxes on/off from Javascript
Posted by Andrew Hill <an...@gridnode.com>.
hmm how about:
document.forms[0].elements['somecheckbox'].checked = false;
any luck with that?
The value property is whats submitted when you submit, so its the
checked property your after, but Id have thought that your
document.getElementById("somecheckbox") should work? Maybe it needs an
explicit id attribute in the tag? (use the styleId attribute of the
struts tag if you need to set it)
dnz wrote:
> Hi all.
>
> I have a struts form bean to populate data on my JSP page which works
> perfectly fine. I use a boolean attribute in my form bean to set the
> checkbox control (at page load time) based on the boolean value. I'm
> using the <html:checkbox .... struts tag for the checkbox controls.
>
> The problem I'm having is .... when my javascript is triggered by
> some event (onclick, etc.), the script is unable to uncheck (at
> runtime) the already checked checkboxes. The script is able to set
> the true/false value to the form bean its just not showing it on my
> JSP page. If I use standard HTML (no JSP / Struts tags) my javascript
> works fine.
>
>
> My javascript goes like this...
>
>
> code:
> --------------------------------------------------------------------------------
>
> document.getElementById("somecheckbox").value = false;
>
> // i've also tried this:
>
> document.getElementById("somecheckbox").checked = false;
>
> --------------------------------------------------------------------------------
>
> Any help would be appreciated.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org