You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Michael C. Lee Jr." <ml...@hotmail.com> on 2003/04/22 16:32:49 UTC

sending value in param on html:select using javascript

How do you call another jsp when an onchange event occurs on html:select with the selected value in the parameter list?

            <html:select property="userRole" size="1">
                <html:option value="">Select User Role</html:option>
                <html:options collection="allUserRoles" property="key" labelProperty="value"/>
            </html:select><font class="bodytextred">*</font>

I want to add an option on html:select for onchange="location.href='/somewhere/some_jsp.jsp?value=****************'"
I want to put what the selected option is where the ************** is. Any ideas?
thanks,
Mike

Re: sending value in param on html:select using javascript

Posted by Ian Hunter <ih...@hunterweb.net>.
I'm missing something.  The suggestion I gave does allow you to control
everything with Javasciprt...

You said you wanted to call another JSP, so there will be some kind of page
refresh visible once they change the select box, and the MVC/Model 2 rule
says you *never* refer to a JSP from another JSP -- everything has to go
through the controller...

What are you trying to avoid by using JavaScript?  Maybe if I understood
more about what you're doing I could give a better suggestion, or at least
go "duh, I don't know"... ;)

----- Original Message -----
From: "Michael C. Lee Jr." <ml...@hotmail.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, April 22, 2003 10:47 AM
Subject: Re: sending value in param on html:select using javascript


> Thanks. I need javascript though. Does anyone know how to do this with
> javascript using the syntax I gave below? I do not want to have to submit
a
> form to an action.
>
> ----- Original Message -----
> From: "Ian Hunter" <ih...@hunterweb.net>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Tuesday, April 22, 2003 10:44 AM
> Subject: Re: sending value in param on html:select using javascript
>
>
> > I use DispatchAction and set the "parameter" or command to something
> > different with JavaScript, then submit the form.  I handle all the tough
> > stuff in the Action class.
> >
> > ----- Original Message -----
> > From: "Michael C. Lee Jr." <ml...@hotmail.com>
> > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Sent: Tuesday, April 22, 2003 10:32 AM
> > Subject: sending value in param on html:select using javascript
> >
> >
> > How do you call another jsp when an onchange event occurs on html:select
> > with the selected value in the parameter list?
> >
> >             <html:select property="userRole" size="1">
> >                 <html:option value="">Select User Role</html:option>
> >                 <html:options collection="allUserRoles" property="key"
> > labelProperty="value"/>
> >             </html:select><font class="bodytextred">*</font>
> >
> > I want to add an option on html:select for
> >
onchange="location.href='/somewhere/some_jsp.jsp?value=****************'"
> > I want to put what the selected option is where the ************** is.
Any
> > ideas?
> > thanks,
> > Mike
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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


Re: sending value in param on html:select using javascript

Posted by "Michael C. Lee Jr." <ml...@hotmail.com>.
Thanks. I need javascript though. Does anyone know how to do this with
javascript using the syntax I gave below? I do not want to have to submit a
form to an action.

----- Original Message -----
From: "Ian Hunter" <ih...@hunterweb.net>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, April 22, 2003 10:44 AM
Subject: Re: sending value in param on html:select using javascript


> I use DispatchAction and set the "parameter" or command to something
> different with JavaScript, then submit the form.  I handle all the tough
> stuff in the Action class.
>
> ----- Original Message -----
> From: "Michael C. Lee Jr." <ml...@hotmail.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Tuesday, April 22, 2003 10:32 AM
> Subject: sending value in param on html:select using javascript
>
>
> How do you call another jsp when an onchange event occurs on html:select
> with the selected value in the parameter list?
>
>             <html:select property="userRole" size="1">
>                 <html:option value="">Select User Role</html:option>
>                 <html:options collection="allUserRoles" property="key"
> labelProperty="value"/>
>             </html:select><font class="bodytextred">*</font>
>
> I want to add an option on html:select for
> onchange="location.href='/somewhere/some_jsp.jsp?value=****************'"
> I want to put what the selected option is where the ************** is. Any
> ideas?
> thanks,
> Mike
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>

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


RE: sending value in param on html:select using javascript

Posted by Mark Galbreath <ma...@qat.com>.
This is relatively easy to do.  First, download a great online reference:

http://developer.netscape.com/docs/manuals/ and look at event handlers,

then think about the <html:form> attribute "onsubmit:"

http://jakarta.apache.org/struts/userGuide/struts-html.html#form

Mark

-----Original Message-----
From: Vangelis Konstantinis [mailto:Vangelis.Konstantinis@eurodyn.com] 
Sent: Tuesday, January 14, 2003 2:42 PM
To: Struts Users Mailing List
Subject: Re: sending value in param on html:select using javascript


Ian hi,

I am new to Struts FrameWork and I have the same problem.

I want on change event of <html:select> to refresh my form and to take new
data.

MyForm - > Action -> Form Again

You take the id of <html:select> and save it to hidden field and then submit
the form????

How do you do this????

I use dispatch Action too.

How do you pass the selected paramenter, and the action you want to execute?

Thanks in advance.

Vangos.
Ian Hunter wrote:

> I use DispatchAction and set the "parameter" or command to something 
> different with JavaScript, then submit the form.  I handle all the 
> tough stuff in the Action class.
>
> ----- Original Message -----
> From: "Michael C. Lee Jr." <ml...@hotmail.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Tuesday, April 22, 2003 10:32 AM
> Subject: sending value in param on html:select using javascript
>
> How do you call another jsp when an onchange event occurs on 
> html:select with the selected value in the parameter list?
>
>             <html:select property="userRole" size="1">
>                 <html:option value="">Select User Role</html:option>
>                 <html:options collection="allUserRoles" property="key" 
> labelProperty="value"/>
>             </html:select><font class="bodytextred">*</font>
>
> I want to add an option on html:select for 
> onchange="location.href='/somewhere/some_jsp.jsp?value=***************
> *'"
> I want to put what the selected option is where the ************** is. Any
> ideas?
> thanks,
> Mike
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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



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


Re: sending value in param on html:select using javascript

Posted by Vangelis Konstantinis <Va...@eurodyn.com>.
Ian hi,

I am new to Struts FrameWork and I have the same problem.

I want on change event of <html:select> to refresh my form and to take new
data.

MyForm - > Action -> Form Again

You take the id of <html:select> and save it to hidden field and then submit
the form????

How do you do this????

I use dispatch Action too.

How do you pass the selected paramenter, and the action you want to execute?

Thanks in advance.

Vangos.
Ian Hunter wrote:

> I use DispatchAction and set the "parameter" or command to something
> different with JavaScript, then submit the form.  I handle all the tough
> stuff in the Action class.
>
> ----- Original Message -----
> From: "Michael C. Lee Jr." <ml...@hotmail.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Tuesday, April 22, 2003 10:32 AM
> Subject: sending value in param on html:select using javascript
>
> How do you call another jsp when an onchange event occurs on html:select
> with the selected value in the parameter list?
>
>             <html:select property="userRole" size="1">
>                 <html:option value="">Select User Role</html:option>
>                 <html:options collection="allUserRoles" property="key"
> labelProperty="value"/>
>             </html:select><font class="bodytextred">*</font>
>
> I want to add an option on html:select for
> onchange="location.href='/somewhere/some_jsp.jsp?value=****************'"
> I want to put what the selected option is where the ************** is. Any
> ideas?
> thanks,
> Mike
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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


Re: sending value in param on html:select using javascript

Posted by Ian Hunter <ih...@hunterweb.net>.
I use DispatchAction and set the "parameter" or command to something
different with JavaScript, then submit the form.  I handle all the tough
stuff in the Action class.

----- Original Message -----
From: "Michael C. Lee Jr." <ml...@hotmail.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, April 22, 2003 10:32 AM
Subject: sending value in param on html:select using javascript


How do you call another jsp when an onchange event occurs on html:select
with the selected value in the parameter list?

            <html:select property="userRole" size="1">
                <html:option value="">Select User Role</html:option>
                <html:options collection="allUserRoles" property="key"
labelProperty="value"/>
            </html:select><font class="bodytextred">*</font>

I want to add an option on html:select for
onchange="location.href='/somewhere/some_jsp.jsp?value=****************'"
I want to put what the selected option is where the ************** is. Any
ideas?
thanks,
Mike


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


Re: sending value in param on html:select using javascript

Posted by James Mitchell <jm...@apache.org>.
I know, I'm lazy, I figured I would let Micael do that ;)  He only asked for
help the javascript, not the resource writing.

--
James Mitchell
Software Developer/Struts Evangelist
http://www.open-tools.org



----- Original Message -----
From: "Ian Hunter" <ih...@hunterweb.net>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, April 22, 2003 11:02 AM
Subject: Re: sending value in param on html:select using javascript


> Anything that constructs a URL using anything other than html:rewrite,
> html:link, or html:img is going to break things -- what if the user
doesn't
> support cookies and you need session tracking?  What if the url map for
> actions has to change from .do to something else?
>
> The struts developers have done a great job of allowing us to do
everything
> we need to with the tags provided...
>
> ----- Original Message -----
> From: "James Mitchell" <jm...@apache.org>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Tuesday, April 22, 2003 10:58 AM
> Subject: Re: sending value in param on html:select using javascript
>
>
> > Hi Michael,
> >
> > Are you sure you want to go to another jsp instead of an action?
> >
> > Anyway, here's something I found on google:
> >
> > <html:select property="userRole" size="1" onchange="GotoURL(this.form)">
> >  <html:option value="">Select User Role</html:option>
> >  <html:options collection="allUserRoles" property="key"
> > labelProperty="value"/>
> > </html:select>
> >
> >
> > <SCRIPT LANGUAGE="JavaScript">
> > function GotoURL(f) {
> >  location.href = "/myapp/dosomething.do?param=" +
> > f.userRole.options[f.userRole.selectedIndex].value;
> > }
> > </SCRIPT>
> >
> >
> > --
> > James Mitchell
> > Software Developer/Struts Evangelist
> > http://www.open-tools.org
> >
> >
> >
> > ----- Original Message -----
> > From: "Michael C. Lee Jr." <ml...@hotmail.com>
> > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Sent: Tuesday, April 22, 2003 10:32 AM
> > Subject: sending value in param on html:select using javascript
> >
> >
> > How do you call another jsp when an onchange event occurs on html:select
> > with the selected value in the parameter list?
> >
> >             <html:select property="userRole" size="1">
> >                 <html:option value="">Select User Role</html:option>
> >                 <html:options collection="allUserRoles" property="key"
> > labelProperty="value"/>
> >             </html:select><font class="bodytextred">*</font>
> >
> > I want to add an option on html:select for
> >
onchange="location.href='/somewhere/some_jsp.jsp?value=****************'"
> > I want to put what the selected option is where the ************** is.
Any
> > ideas?
> > thanks,
> > Mike
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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


Re: sending value in param on html:select using javascript

Posted by Ian Hunter <ih...@hunterweb.net>.
Anything that constructs a URL using anything other than html:rewrite,
html:link, or html:img is going to break things -- what if the user doesn't
support cookies and you need session tracking?  What if the url map for
actions has to change from .do to something else?

The struts developers have done a great job of allowing us to do everything
we need to with the tags provided...

----- Original Message -----
From: "James Mitchell" <jm...@apache.org>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, April 22, 2003 10:58 AM
Subject: Re: sending value in param on html:select using javascript


> Hi Michael,
>
> Are you sure you want to go to another jsp instead of an action?
>
> Anyway, here's something I found on google:
>
> <html:select property="userRole" size="1" onchange="GotoURL(this.form)">
>  <html:option value="">Select User Role</html:option>
>  <html:options collection="allUserRoles" property="key"
> labelProperty="value"/>
> </html:select>
>
>
> <SCRIPT LANGUAGE="JavaScript">
> function GotoURL(f) {
>  location.href = "/myapp/dosomething.do?param=" +
> f.userRole.options[f.userRole.selectedIndex].value;
> }
> </SCRIPT>
>
>
> --
> James Mitchell
> Software Developer/Struts Evangelist
> http://www.open-tools.org
>
>
>
> ----- Original Message -----
> From: "Michael C. Lee Jr." <ml...@hotmail.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Tuesday, April 22, 2003 10:32 AM
> Subject: sending value in param on html:select using javascript
>
>
> How do you call another jsp when an onchange event occurs on html:select
> with the selected value in the parameter list?
>
>             <html:select property="userRole" size="1">
>                 <html:option value="">Select User Role</html:option>
>                 <html:options collection="allUserRoles" property="key"
> labelProperty="value"/>
>             </html:select><font class="bodytextred">*</font>
>
> I want to add an option on html:select for
> onchange="location.href='/somewhere/some_jsp.jsp?value=****************'"
> I want to put what the selected option is where the ************** is. Any
> ideas?
> thanks,
> Mike
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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


Re: sending value in param on html:select using javascript

Posted by James Mitchell <jm...@apache.org>.
Hi Michael,

Are you sure you want to go to another jsp instead of an action?

Anyway, here's something I found on google:

<html:select property="userRole" size="1" onchange="GotoURL(this.form)">
 <html:option value="">Select User Role</html:option>
 <html:options collection="allUserRoles" property="key"
labelProperty="value"/>
</html:select>


<SCRIPT LANGUAGE="JavaScript">
function GotoURL(f) {
 location.href = "/myapp/dosomething.do?param=" +
f.userRole.options[f.userRole.selectedIndex].value;
}
</SCRIPT>


--
James Mitchell
Software Developer/Struts Evangelist
http://www.open-tools.org



----- Original Message -----
From: "Michael C. Lee Jr." <ml...@hotmail.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, April 22, 2003 10:32 AM
Subject: sending value in param on html:select using javascript


How do you call another jsp when an onchange event occurs on html:select
with the selected value in the parameter list?

            <html:select property="userRole" size="1">
                <html:option value="">Select User Role</html:option>
                <html:options collection="allUserRoles" property="key"
labelProperty="value"/>
            </html:select><font class="bodytextred">*</font>

I want to add an option on html:select for
onchange="location.href='/somewhere/some_jsp.jsp?value=****************'"
I want to put what the selected option is where the ************** is. Any
ideas?
thanks,
Mike


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