It's not a secret anymore!
The moose likes Struts and the fly likes Passing a Form Parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Passing a Form Parameter" Watch "Passing a Form Parameter" New topic

Passing a Form Parameter

Sege Stephen
Ranch Hand

Joined: Oct 06, 2007
Posts: 51
Hi, I have two similar forms on a page. They are select boxes,
I know how to pass the options in the select box drop down as
a parameter, but what of if I want to a parameter so that
depending on which of the Select boxes I select a value from,
a parameter is passed. I have two of this forms in my code,
I can select an option from either, and then go to the next page.
But I need to pass a parameter, so that I would know which of
Select boxs I have clicked from, because that would determine
what query is run on the subsquent pages. This parameter can
be attached anywhere, ie with the sumbit buttons, or anywhere
in the form.

All I want is if I select an option from select dropdown 1, a
parameter called box1 is passed, if I select from drowdown 2 ,
a parameter box 2 is passed.

Here is my code

[ December 04, 2007: Message edited by: Ben Souther ]
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

It looks like you're writing your pages with Struts.
Since Struts offers its own solutions to a lot of typical problems, you're probably better off asking in our Struts forum.
I'll move this thread over there for you.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Sege Stephen
Ranch Hand

Joined: Oct 06, 2007
Posts: 51
Ben, Sorry. Yes I am using struts for my application, I posted it on the JSP forum because I thought my problem had to do with a JSP page. Anyway thanks for letting me know, knowing that will let me get better and quicker answers next time, also it would me less work for you as well.

Beside, I found the solution to my problem, I try to solve it before posting it here, but once I am getting no where, I thought it was better to as.

I solve it by adding a single line to my code

<input type="hidden" name="param_name" value="box1" />
I agree. Here's the link:
subject: Passing a Form Parameter
It's not a secret anymore!