aspose file tools*
The moose likes Beginning Java and the fly likes assign dropdown selected value to a java variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "assign dropdown selected value to a java variable" Watch "assign dropdown selected value to a java variable" New topic
Author

assign dropdown selected value to a java variable

khamhielle gabriel
Greenhorn

Joined: Aug 15, 2011
Posts: 19
hi,

i have a drop down in <form name=dropdown> and i need to submit its value to the next page,
by clicking a button in another <form>
the next page is with String x= request.getParameter and i am getting null.

how can i able to resolve such.


<form name = dropdownn action="a.jsp">
<select name "select">
<option>1</option>
<option>2</option>
</select>
</form>

<form name= button action="b.jsp">

<input type ="submit">click</input> --------------------------> this button should send the selected value
</form>



the reason why the button is on the second form is for design purposes.


sorry im really not good at this.


thank you so much.

God Bless you
Saikat Roy Mahasay
Greenhorn

Joined: Jan 12, 2012
Posts: 10

I think you want to submit the first form, rather than the second. The submit button in the provided code submits the second form. Hence your parameter is null.

You could try to change the submit to a button or link, and use javascript to submit the other form like or

All the best.
khamhielle gabriel
Greenhorn

Joined: Aug 15, 2011
Posts: 19
thank you so much for your reply roy

and yuo are correct.

i want to pass the first' forms value rather than the second one.


in relation to your suggestion can you hand me some example on how could i be able to use document.dropdown.submit() ?

again sorry for not knowing it.

thanks
Saikat Roy Mahasay
Greenhorn

Joined: Jan 12, 2012
Posts: 10

Hello Gabriel

The code you posted is not complete, and I could not get the first form from it. Here's a sugestion though :-

1. Add a bit of javascript in your code, like this:



2. Call this in the onClick of your button, by the way, I think you should make it a button instead of submit. I am not sure of this, but it seems counter-intuitive(and unlikely) that 2 forms can be submit concurrently.



Hope this helps.
Regards
Saikat
khamhielle gabriel
Greenhorn

Joined: Aug 15, 2011
Posts: 19
forgot to end this topic

its case solve

my overwhelming gratitude to you saikat.

GOD Bless you always
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: assign dropdown selected value to a java variable