You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Uday Chandra Karrothi <ud...@gmail.com> on 2006/09/26 20:24:37 UTC
Multiple radio button groups
Hi there,
I have a problem. I am using groups of radio buttons.
<logic:iterate id="apprEntry" name="listDevApprGrpList" indexId="userIndex">
..
<html:radio value="A" name="apprEntry" property="primary_or_adjunct"
indexed="true" onclick="">Pri.</html:radio>
<html:radio value="B" name="apprEntry" property="primary_or_adjunct"
indexed="true" onclick="">Adj.</html:radio>
..
How can get the value of the selected radio buttons in the action
form. Is there something
like a multibox for a radio group?
if it is just one radio button group, i can get it from the property
of the form bean. But when i there are multiple radio button groups,
then how do i get the value of each of the button groups.
I already spent a day of my time on this. Please advice me on this.
Please direct me to the right resource
Thank you,
Uday Karrothi
--
Never explain--your friends do not need it and your enemies will not
believe you anyway--Elbert Hubbard
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Multiple radio button groups
Posted by Chris Pratt <th...@gmail.com>.
I think I see the problem, it was with my example, it should have been:
var value = radioValue(document.formName.elements["apprEntry[0].primary_or_adjunct"]);
where "formName" is the value of the name attribute of the form tag.
(*Chris*)
On 9/26/06, Uday Chandra Karrothi <ud...@gmail.com> wrote:
>
> Thanks Chris,
>
> The request.getParameter works. I think i am going to go with that.
> the javascript was throwing soem errors. I will figure that out later.
>
> Thanks for the help once again.
>
> Later
> Uday Chandra
>
>
> On 9/26/06, Chris Pratt <th...@gmail.com> wrote:
> > Wow, those are some ugly field names, but you should be able to access
> it
> > from either. In JavaScript I would probably use a helper function
> something
> > like:
> >
> > function radioValue (fld) {
> > for(var i = 0; i < fld.length;i++) {
> > if(fld[i].checked) {
> > return fld[i].value;
> > }
> > }
> > return fld[0].value;
> > } //radioValue
> >
> > Then you could access the value as:
> >
> > var value = radioValue(document.forms
> ["apprEntry[0].primary_or_adjunct"]);
> >
> > In Java you could just use:
> >
> > String value = request.getParameter("apprEntry[0].primary_or_adjunct");
> >
> > (*Chris*)
> >
> > On 9/26/06, Uday Chandra Karrothi <ud...@gmail.com> wrote:
> > >
> > > Thanks Chris for the response.
> > >
> > > But here is the problem.
> > > <logic:iterate id="apprEntry" name="listDevApprGrpList"
> > > indexId="userIndex">
> > > ..
> > > <html:radio value="A" name="apprEntry" property="primary_or_adjunct"
> > > indexed="true" onclick="">Pri.</html:radio>
> > > <html:radio value="B" name="apprEntry" property="primary_or_adjunct"
> > > indexed="true" onclick="">Adj.</html:radio>
> > > ..
> > >
> > > The resultant html code is
> > > ...
> > > <input type="radio"
> > > name="apprEntry[0].primary_or_adjunct"
> > > value="A" checked="checked" onclick="">Pri.
> > > <input type="radio"
> > > name="apprEntry[0].primary_or_adjunct"
> > > value="B" onclick="">Adj.
> > > ...
> > >
> > > <input type="radio"
> > > name="apprEntry[1].primary_or_adjunct"
> > > value="A" checked="checked" onclick="">Pri.
> > > <input type="radio"
> > > name="apprEntry[1].primary_or_adjunct"
> > > value="B" onclick="">Adj.
> > > ...
> > >
> > > You are right to say that the all the radio with the same name are
> > > considered in one group .
> > >
> > > Now how do i obtain the value or which radio button is checked. Can I
> > > access in Javascript or in the action class.?
> > >
> > > Please do let me know. Thank you for your response once again.
> > >
> > > Uday Karrothi
> > >
> > > On 9/26/06, Chris Pratt <th...@gmail.com> wrote:
> > > > All the radio buttons (or checkboxes) with the same name are in a
> > > "button
> > > > group". The value of the selected radio button (or list of selected
> > > > checkboxes) is returned from request.getParameter() (or
> > > > request.getParameterValues()).
> > > > (*Chris*)
> > > >
> > > > On 9/26/06, Uday Chandra Karrothi <ud...@gmail.com> wrote:
> > > > >
> > > > > Hi there,
> > > > >
> > > > > I have a problem. I am using groups of radio buttons.
> > > > >
> > > > >
> > > > >
> > > > > <logic:iterate id="apprEntry" name="listDevApprGrpList"
> > > > > indexId="userIndex">
> > > > >
> > > > > ..
> > > > >
> > > > > <html:radio value="A" name="apprEntry"
> property="primary_or_adjunct"
> > > > > indexed="true" onclick="">Pri.</html:radio>
> > > > >
> > > > > <html:radio value="B" name="apprEntry"
> property="primary_or_adjunct"
> > > > > indexed="true" onclick="">Adj.</html:radio>
> > > > >
> > > > > ..
> > > > >
> > > > >
> > > > > How can get the value of the selected radio buttons in the action
> > > > > form. Is there something
> > > > > like a multibox for a radio group?
> > > > > if it is just one radio button group, i can get it from the
> property
> > > > > of the form bean. But when i there are multiple radio button
> groups,
> > > > > then how do i get the value of each of the button groups.
> > > > >
> > > > >
> > > > > I already spent a day of my time on this. Please advice me on
> this.
> > > > > Please direct me to the right resource
> > > > >
> > > > > Thank you,
> > > > > Uday Karrothi
> > > > >
> > > > > --
> > > > > Never explain--your friends do not need it and your enemies will
> not
> > > > > believe you anyway--Elbert Hubbard
> > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > > For additional commands, e-mail: user-help@struts.apache.org
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > Never explain--your friends do not need it and your enemies will not
> > > believe you anyway--Elbert Hubbard
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
> >
>
>
> --
> Never explain--your friends do not need it and your enemies will not
> believe you anyway--Elbert Hubbard
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: Multiple radio button groups
Posted by Uday Chandra Karrothi <ud...@gmail.com>.
Thanks Chris,
The request.getParameter works. I think i am going to go with that.
the javascript was throwing soem errors. I will figure that out later.
Thanks for the help once again.
Later
Uday Chandra
On 9/26/06, Chris Pratt <th...@gmail.com> wrote:
> Wow, those are some ugly field names, but you should be able to access it
> from either. In JavaScript I would probably use a helper function something
> like:
>
> function radioValue (fld) {
> for(var i = 0; i < fld.length;i++) {
> if(fld[i].checked) {
> return fld[i].value;
> }
> }
> return fld[0].value;
> } //radioValue
>
> Then you could access the value as:
>
> var value = radioValue(document.forms["apprEntry[0].primary_or_adjunct"]);
>
> In Java you could just use:
>
> String value = request.getParameter("apprEntry[0].primary_or_adjunct");
>
> (*Chris*)
>
> On 9/26/06, Uday Chandra Karrothi <ud...@gmail.com> wrote:
> >
> > Thanks Chris for the response.
> >
> > But here is the problem.
> > <logic:iterate id="apprEntry" name="listDevApprGrpList"
> > indexId="userIndex">
> > ..
> > <html:radio value="A" name="apprEntry" property="primary_or_adjunct"
> > indexed="true" onclick="">Pri.</html:radio>
> > <html:radio value="B" name="apprEntry" property="primary_or_adjunct"
> > indexed="true" onclick="">Adj.</html:radio>
> > ..
> >
> > The resultant html code is
> > ...
> > <input type="radio"
> > name="apprEntry[0].primary_or_adjunct"
> > value="A" checked="checked" onclick="">Pri.
> > <input type="radio"
> > name="apprEntry[0].primary_or_adjunct"
> > value="B" onclick="">Adj.
> > ...
> >
> > <input type="radio"
> > name="apprEntry[1].primary_or_adjunct"
> > value="A" checked="checked" onclick="">Pri.
> > <input type="radio"
> > name="apprEntry[1].primary_or_adjunct"
> > value="B" onclick="">Adj.
> > ...
> >
> > You are right to say that the all the radio with the same name are
> > considered in one group .
> >
> > Now how do i obtain the value or which radio button is checked. Can I
> > access in Javascript or in the action class.?
> >
> > Please do let me know. Thank you for your response once again.
> >
> > Uday Karrothi
> >
> > On 9/26/06, Chris Pratt <th...@gmail.com> wrote:
> > > All the radio buttons (or checkboxes) with the same name are in a
> > "button
> > > group". The value of the selected radio button (or list of selected
> > > checkboxes) is returned from request.getParameter() (or
> > > request.getParameterValues()).
> > > (*Chris*)
> > >
> > > On 9/26/06, Uday Chandra Karrothi <ud...@gmail.com> wrote:
> > > >
> > > > Hi there,
> > > >
> > > > I have a problem. I am using groups of radio buttons.
> > > >
> > > >
> > > >
> > > > <logic:iterate id="apprEntry" name="listDevApprGrpList"
> > > > indexId="userIndex">
> > > >
> > > > ..
> > > >
> > > > <html:radio value="A" name="apprEntry" property="primary_or_adjunct"
> > > > indexed="true" onclick="">Pri.</html:radio>
> > > >
> > > > <html:radio value="B" name="apprEntry" property="primary_or_adjunct"
> > > > indexed="true" onclick="">Adj.</html:radio>
> > > >
> > > > ..
> > > >
> > > >
> > > > How can get the value of the selected radio buttons in the action
> > > > form. Is there something
> > > > like a multibox for a radio group?
> > > > if it is just one radio button group, i can get it from the property
> > > > of the form bean. But when i there are multiple radio button groups,
> > > > then how do i get the value of each of the button groups.
> > > >
> > > >
> > > > I already spent a day of my time on this. Please advice me on this.
> > > > Please direct me to the right resource
> > > >
> > > > Thank you,
> > > > Uday Karrothi
> > > >
> > > > --
> > > > Never explain--your friends do not need it and your enemies will not
> > > > believe you anyway--Elbert Hubbard
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail: user-help@struts.apache.org
> > > >
> > > >
> > >
> > >
> >
> >
> > --
> > Never explain--your friends do not need it and your enemies will not
> > believe you anyway--Elbert Hubbard
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
--
Never explain--your friends do not need it and your enemies will not
believe you anyway--Elbert Hubbard
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Multiple radio button groups
Posted by Chris Pratt <th...@gmail.com>.
Wow, those are some ugly field names, but you should be able to access it
from either. In JavaScript I would probably use a helper function something
like:
function radioValue (fld) {
for(var i = 0; i < fld.length;i++) {
if(fld[i].checked) {
return fld[i].value;
}
}
return fld[0].value;
} //radioValue
Then you could access the value as:
var value = radioValue(document.forms["apprEntry[0].primary_or_adjunct"]);
In Java you could just use:
String value = request.getParameter("apprEntry[0].primary_or_adjunct");
(*Chris*)
On 9/26/06, Uday Chandra Karrothi <ud...@gmail.com> wrote:
>
> Thanks Chris for the response.
>
> But here is the problem.
> <logic:iterate id="apprEntry" name="listDevApprGrpList"
> indexId="userIndex">
> ..
> <html:radio value="A" name="apprEntry" property="primary_or_adjunct"
> indexed="true" onclick="">Pri.</html:radio>
> <html:radio value="B" name="apprEntry" property="primary_or_adjunct"
> indexed="true" onclick="">Adj.</html:radio>
> ..
>
> The resultant html code is
> ...
> <input type="radio"
> name="apprEntry[0].primary_or_adjunct"
> value="A" checked="checked" onclick="">Pri.
> <input type="radio"
> name="apprEntry[0].primary_or_adjunct"
> value="B" onclick="">Adj.
> ...
>
> <input type="radio"
> name="apprEntry[1].primary_or_adjunct"
> value="A" checked="checked" onclick="">Pri.
> <input type="radio"
> name="apprEntry[1].primary_or_adjunct"
> value="B" onclick="">Adj.
> ...
>
> You are right to say that the all the radio with the same name are
> considered in one group .
>
> Now how do i obtain the value or which radio button is checked. Can I
> access in Javascript or in the action class.?
>
> Please do let me know. Thank you for your response once again.
>
> Uday Karrothi
>
> On 9/26/06, Chris Pratt <th...@gmail.com> wrote:
> > All the radio buttons (or checkboxes) with the same name are in a
> "button
> > group". The value of the selected radio button (or list of selected
> > checkboxes) is returned from request.getParameter() (or
> > request.getParameterValues()).
> > (*Chris*)
> >
> > On 9/26/06, Uday Chandra Karrothi <ud...@gmail.com> wrote:
> > >
> > > Hi there,
> > >
> > > I have a problem. I am using groups of radio buttons.
> > >
> > >
> > >
> > > <logic:iterate id="apprEntry" name="listDevApprGrpList"
> > > indexId="userIndex">
> > >
> > > ..
> > >
> > > <html:radio value="A" name="apprEntry" property="primary_or_adjunct"
> > > indexed="true" onclick="">Pri.</html:radio>
> > >
> > > <html:radio value="B" name="apprEntry" property="primary_or_adjunct"
> > > indexed="true" onclick="">Adj.</html:radio>
> > >
> > > ..
> > >
> > >
> > > How can get the value of the selected radio buttons in the action
> > > form. Is there something
> > > like a multibox for a radio group?
> > > if it is just one radio button group, i can get it from the property
> > > of the form bean. But when i there are multiple radio button groups,
> > > then how do i get the value of each of the button groups.
> > >
> > >
> > > I already spent a day of my time on this. Please advice me on this.
> > > Please direct me to the right resource
> > >
> > > Thank you,
> > > Uday Karrothi
> > >
> > > --
> > > Never explain--your friends do not need it and your enemies will not
> > > believe you anyway--Elbert Hubbard
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
> >
>
>
> --
> Never explain--your friends do not need it and your enemies will not
> believe you anyway--Elbert Hubbard
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: Multiple radio button groups
Posted by Uday Chandra Karrothi <ud...@gmail.com>.
Thanks Chris for the response.
But here is the problem.
<logic:iterate id="apprEntry" name="listDevApprGrpList" indexId="userIndex">
..
<html:radio value="A" name="apprEntry" property="primary_or_adjunct"
indexed="true" onclick="">Pri.</html:radio>
<html:radio value="B" name="apprEntry" property="primary_or_adjunct"
indexed="true" onclick="">Adj.</html:radio>
..
The resultant html code is
...
<input type="radio" name="apprEntry[0].primary_or_adjunct"
value="A" checked="checked" onclick="">Pri.
<input type="radio" name="apprEntry[0].primary_or_adjunct"
value="B" onclick="">Adj.
...
<input type="radio" name="apprEntry[1].primary_or_adjunct"
value="A" checked="checked" onclick="">Pri.
<input type="radio" name="apprEntry[1].primary_or_adjunct"
value="B" onclick="">Adj.
...
You are right to say that the all the radio with the same name are
considered in one group .
Now how do i obtain the value or which radio button is checked. Can I
access in Javascript or in the action class.?
Please do let me know. Thank you for your response once again.
Uday Karrothi
On 9/26/06, Chris Pratt <th...@gmail.com> wrote:
> All the radio buttons (or checkboxes) with the same name are in a "button
> group". The value of the selected radio button (or list of selected
> checkboxes) is returned from request.getParameter() (or
> request.getParameterValues()).
> (*Chris*)
>
> On 9/26/06, Uday Chandra Karrothi <ud...@gmail.com> wrote:
> >
> > Hi there,
> >
> > I have a problem. I am using groups of radio buttons.
> >
> >
> >
> > <logic:iterate id="apprEntry" name="listDevApprGrpList"
> > indexId="userIndex">
> >
> > ..
> >
> > <html:radio value="A" name="apprEntry" property="primary_or_adjunct"
> > indexed="true" onclick="">Pri.</html:radio>
> >
> > <html:radio value="B" name="apprEntry" property="primary_or_adjunct"
> > indexed="true" onclick="">Adj.</html:radio>
> >
> > ..
> >
> >
> > How can get the value of the selected radio buttons in the action
> > form. Is there something
> > like a multibox for a radio group?
> > if it is just one radio button group, i can get it from the property
> > of the form bean. But when i there are multiple radio button groups,
> > then how do i get the value of each of the button groups.
> >
> >
> > I already spent a day of my time on this. Please advice me on this.
> > Please direct me to the right resource
> >
> > Thank you,
> > Uday Karrothi
> >
> > --
> > Never explain--your friends do not need it and your enemies will not
> > believe you anyway--Elbert Hubbard
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
--
Never explain--your friends do not need it and your enemies will not
believe you anyway--Elbert Hubbard
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Multiple radio button groups
Posted by Chris Pratt <th...@gmail.com>.
All the radio buttons (or checkboxes) with the same name are in a "button
group". The value of the selected radio button (or list of selected
checkboxes) is returned from request.getParameter() (or
request.getParameterValues()).
(*Chris*)
On 9/26/06, Uday Chandra Karrothi <ud...@gmail.com> wrote:
>
> Hi there,
>
> I have a problem. I am using groups of radio buttons.
>
>
>
> <logic:iterate id="apprEntry" name="listDevApprGrpList"
> indexId="userIndex">
>
> ..
>
> <html:radio value="A" name="apprEntry" property="primary_or_adjunct"
> indexed="true" onclick="">Pri.</html:radio>
>
> <html:radio value="B" name="apprEntry" property="primary_or_adjunct"
> indexed="true" onclick="">Adj.</html:radio>
>
> ..
>
>
> How can get the value of the selected radio buttons in the action
> form. Is there something
> like a multibox for a radio group?
> if it is just one radio button group, i can get it from the property
> of the form bean. But when i there are multiple radio button groups,
> then how do i get the value of each of the button groups.
>
>
> I already spent a day of my time on this. Please advice me on this.
> Please direct me to the right resource
>
> Thank you,
> Uday Karrothi
>
> --
> Never explain--your friends do not need it and your enemies will not
> believe you anyway--Elbert Hubbard
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: Multiple radio button groups
Posted by yamilka vallejo ramos <ya...@gmail.com>.
Hi, look I work with that and the way that I do it, its asking in the
actionForm by the value of the radioButton
I mean:
In my case in the JSP I put this:
<html:radio property="anestesico" value="medicacionNA" />
<html:radio property="anestesico" value="farmacoA" />
And in the ActionForm:
if(gestionarEdicionFarmacoMedicacionForm.
getAnestesico().matches("farmacoA")){ ... }
thats because I just have to radioGroup.
enjoy ;)
2006/9/26, Uday Chandra Karrothi <ud...@gmail.com>:
>
> Hi there,
>
> I have a problem. I am using groups of radio buttons.
>
>
>
> <logic:iterate id="apprEntry" name="listDevApprGrpList"
> indexId="userIndex">
>
> ..
>
> <html:radio value="A" name="apprEntry" property="primary_or_adjunct"
> indexed="true" onclick="">Pri.</html:radio>
>
> <html:radio value="B" name="apprEntry" property="primary_or_adjunct"
> indexed="true" onclick="">Adj.</html:radio>
>
> ..
>
>
> How can get the value of the selected radio buttons in the action
> form. Is there something
> like a multibox for a radio group?
> if it is just one radio button group, i can get it from the property
> of the form bean. But when i there are multiple radio button groups,
> then how do i get the value of each of the button groups.
>
>
> I already spent a day of my time on this. Please advice me on this.
> Please direct me to the right resource
>
> Thank you,
> Uday Karrothi
>
> --
> Never explain--your friends do not need it and your enemies will not
> believe you anyway--Elbert Hubbard
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>