You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Bill Siggelkow <bi...@bellsouth.net> on 2004/07/09 15:21:10 UTC

Re: country state swapping in struts

There are several different ways of handling this ... the easiest is to 
just use JavaScript -- you can hard-code JavaScript arrays -- or 
generate JavaScript arrays using Struts or JSTL tags -- or you can 
retrieve the list of states on the fly by using an onchange listener on 
the country field. The latter approach allows the most dynamic ability --
The JSP below shows how you could change the options displayed in a 
select based on the selection of a radio button.

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html>
<head>
   <title>Struts – JavaScript Example</title>
   <script language="JavaScript">
      function getOptions(control) {
         form = control.form;
         form.action = "SetOptions.do?someProp=";
         form.action += control.value;
         form.submit();
      }
    </script>
</head>
<body>
   <html:form action="ProcessMyForm">
       <html:radio property="someProp1" value="val1"
                    onclick="getOptions(this);"/> Value 1<br/>
       <html:radio property="language" value="val2"
                    onclick="getOptions(this);"/> Value 2<br/>
       SomeProp2:
       <html:select property="someProp2">
          <html:optionsCollection property="prop2Values"/>
       </html:select>
       </p>
       <html:submit/>
   </html:form>
</body>
</html>


Jignesh Patel wrote:

> Hi All,
> In our application when user selects country like USA or Canada in turn
> it has to show corresponding country's states.
> 
> Is there any struts example available for the same.
> 
> -Jignesh


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


RE: country state swapping in struts

Posted by Andrew Hill <an...@gridnode.com>.
Oh thank goodness. Its not just me who couldnt parse it. I thought for a moment my brain was having a buffer overrun or something.

-----Original Message-----
From: James Mitchell [mailto:jmitchell@apache.org]
Sent: Saturday, 10 July 2004 01:17
To: Struts Users Mailing List
Subject: Re: country state swapping in struts


I believe he said "it only rains in the summer years over a banana".....;)


--
James Mitchell
Software Engineer / Open Source Evangelist
EdgeTech, Inc.
678.910.8017
AIM: jmitchtx

----- Original Message -----
From: "Bill Siggelkow" <bi...@bellsouth.net>
To: <us...@struts.apache.org>
Sent: Friday, July 09, 2004 1:05 PM
Subject: Re: country state swapping in struts


> Exsqueezeme?
>
> Jignesh Patel wrote:
>
> > Thanks,
> > For information but we are facing one more problem we are able to set
> > with java script but while givin form update feature it is not working
> > as expected.
> >
> > -Jignesh
> > On Fri, 2004-07-09 at 09:21, Bill Siggelkow wrote:
> >
> >>There are several different ways of handling this ... the easiest is to
> >>just use JavaScript -- you can hard-code JavaScript arrays -- or
> >>generate JavaScript arrays using Struts or JSTL tags -- or you can
> >>retrieve the list of states on the fly by using an onchange listener on
> >>the country field. The latter approach allows the most dynamic
ability --
> >>The JSP below shows how you could change the options displayed in a
> >>select based on the selection of a radio button.
> >>
> >><%@ page contentType="text/html;charset=UTF-8" language="java" %>
> >><%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
> >><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
> >><html>
> >><head>
> >>   <title>Struts – JavaScript Example</title>
> >>   <script language="JavaScript">
> >>      function getOptions(control) {
> >>         form = control.form;
> >>         form.action = "SetOptions.do?someProp=";
> >>         form.action += control.value;
> >>         form.submit();
> >>      }
> >>    </script>
> >></head>
> >><body>
> >>   <html:form action="ProcessMyForm">
> >>       <html:radio property="someProp1" value="val1"
> >>                    onclick="getOptions(this);"/> Value 1<br/>
> >>       <html:radio property="language" value="val2"
> >>                    onclick="getOptions(this);"/> Value 2<br/>
> >>       SomeProp2:
> >>       <html:select property="someProp2">
> >>          <html:optionsCollection property="prop2Values"/>
> >>       </html:select>
> >>       </p>
> >>       <html:submit/>
> >>   </html:form>
> >></body>
> >></html>
> >>
> >>
> >>Jignesh Patel wrote:
> >>
> >>
> >>>Hi All,
> >>>In our application when user selects country like USA or Canada in turn
> >>>it has to show corresponding country's states.
> >>>
> >>>Is there any struts example available for the same.
> >>>
> >>>-Jignesh
> >>
> >>
> >>---------------------------------------------------------------------
> >>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
>
>



---------------------------------------------------------------------
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


Re: country state swapping in struts

Posted by James Mitchell <jm...@apache.org>.
I believe he said "it only rains in the summer years over a banana".....;)


--
James Mitchell
Software Engineer / Open Source Evangelist
EdgeTech, Inc.
678.910.8017
AIM: jmitchtx

----- Original Message -----
From: "Bill Siggelkow" <bi...@bellsouth.net>
To: <us...@struts.apache.org>
Sent: Friday, July 09, 2004 1:05 PM
Subject: Re: country state swapping in struts


> Exsqueezeme?
>
> Jignesh Patel wrote:
>
> > Thanks,
> > For information but we are facing one more problem we are able to set
> > with java script but while givin form update feature it is not working
> > as expected.
> >
> > -Jignesh
> > On Fri, 2004-07-09 at 09:21, Bill Siggelkow wrote:
> >
> >>There are several different ways of handling this ... the easiest is to
> >>just use JavaScript -- you can hard-code JavaScript arrays -- or
> >>generate JavaScript arrays using Struts or JSTL tags -- or you can
> >>retrieve the list of states on the fly by using an onchange listener on
> >>the country field. The latter approach allows the most dynamic
ability --
> >>The JSP below shows how you could change the options displayed in a
> >>select based on the selection of a radio button.
> >>
> >><%@ page contentType="text/html;charset=UTF-8" language="java" %>
> >><%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
> >><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
> >><html>
> >><head>
> >>   <title>Struts – JavaScript Example</title>
> >>   <script language="JavaScript">
> >>      function getOptions(control) {
> >>         form = control.form;
> >>         form.action = "SetOptions.do?someProp=";
> >>         form.action += control.value;
> >>         form.submit();
> >>      }
> >>    </script>
> >></head>
> >><body>
> >>   <html:form action="ProcessMyForm">
> >>       <html:radio property="someProp1" value="val1"
> >>                    onclick="getOptions(this);"/> Value 1<br/>
> >>       <html:radio property="language" value="val2"
> >>                    onclick="getOptions(this);"/> Value 2<br/>
> >>       SomeProp2:
> >>       <html:select property="someProp2">
> >>          <html:optionsCollection property="prop2Values"/>
> >>       </html:select>
> >>       </p>
> >>       <html:submit/>
> >>   </html:form>
> >></body>
> >></html>
> >>
> >>
> >>Jignesh Patel wrote:
> >>
> >>
> >>>Hi All,
> >>>In our application when user selects country like USA or Canada in turn
> >>>it has to show corresponding country's states.
> >>>
> >>>Is there any struts example available for the same.
> >>>
> >>>-Jignesh
> >>
> >>
> >>---------------------------------------------------------------------
> >>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
>
>



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


Re: country state swapping in struts

Posted by Bill Siggelkow <bi...@bellsouth.net>.
Exsqueezeme?

Jignesh Patel wrote:

> Thanks,
> For information but we are facing one more problem we are able to set
> with java script but while givin form update feature it is not working
> as expected.
> 
> -Jignesh
> On Fri, 2004-07-09 at 09:21, Bill Siggelkow wrote:
> 
>>There are several different ways of handling this ... the easiest is to 
>>just use JavaScript -- you can hard-code JavaScript arrays -- or 
>>generate JavaScript arrays using Struts or JSTL tags -- or you can 
>>retrieve the list of states on the fly by using an onchange listener on 
>>the country field. The latter approach allows the most dynamic ability --
>>The JSP below shows how you could change the options displayed in a 
>>select based on the selection of a radio button.
>>
>><%@ page contentType="text/html;charset=UTF-8" language="java" %>
>><%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
>><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
>><html>
>><head>
>>   <title>Struts – JavaScript Example</title>
>>   <script language="JavaScript">
>>      function getOptions(control) {
>>         form = control.form;
>>         form.action = "SetOptions.do?someProp=";
>>         form.action += control.value;
>>         form.submit();
>>      }
>>    </script>
>></head>
>><body>
>>   <html:form action="ProcessMyForm">
>>       <html:radio property="someProp1" value="val1"
>>                    onclick="getOptions(this);"/> Value 1<br/>
>>       <html:radio property="language" value="val2"
>>                    onclick="getOptions(this);"/> Value 2<br/>
>>       SomeProp2:
>>       <html:select property="someProp2">
>>          <html:optionsCollection property="prop2Values"/>
>>       </html:select>
>>       </p>
>>       <html:submit/>
>>   </html:form>
>></body>
>></html>
>>
>>
>>Jignesh Patel wrote:
>>
>>
>>>Hi All,
>>>In our application when user selects country like USA or Canada in turn
>>>it has to show corresponding country's states.
>>>
>>>Is there any struts example available for the same.
>>>
>>>-Jignesh
>>
>>
>>---------------------------------------------------------------------
>>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


Re: country state swapping in struts

Posted by Jignesh Patel <jp...@bangtechnology.com>.
Thanks,
For information but we are facing one more problem we are able to set
with java script but while givin form update feature it is not working
as expected.

-Jignesh
On Fri, 2004-07-09 at 09:21, Bill Siggelkow wrote:
> There are several different ways of handling this ... the easiest is to 
> just use JavaScript -- you can hard-code JavaScript arrays -- or 
> generate JavaScript arrays using Struts or JSTL tags -- or you can 
> retrieve the list of states on the fly by using an onchange listener on 
> the country field. The latter approach allows the most dynamic ability --
> The JSP below shows how you could change the options displayed in a 
> select based on the selection of a radio button.
> 
> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
> <html>
> <head>
>    <title>Struts – JavaScript Example</title>
>    <script language="JavaScript">
>       function getOptions(control) {
>          form = control.form;
>          form.action = "SetOptions.do?someProp=";
>          form.action += control.value;
>          form.submit();
>       }
>     </script>
> </head>
> <body>
>    <html:form action="ProcessMyForm">
>        <html:radio property="someProp1" value="val1"
>                     onclick="getOptions(this);"/> Value 1<br/>
>        <html:radio property="language" value="val2"
>                     onclick="getOptions(this);"/> Value 2<br/>
>        SomeProp2:
>        <html:select property="someProp2">
>           <html:optionsCollection property="prop2Values"/>
>        </html:select>
>        </p>
>        <html:submit/>
>    </html:form>
> </body>
> </html>
> 
> 
> Jignesh Patel wrote:
> 
> > Hi All,
> > In our application when user selects country like USA or Canada in turn
> > it has to show corresponding country's states.
> > 
> > Is there any struts example available for the same.
> > 
> > -Jignesh
> 
> 
> ---------------------------------------------------------------------
> 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