This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Dropdown always selects the first value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Dropdown always selects the first value" Watch "Dropdown always selects the first value" New topic
Author

Dropdown always selects the first value

Nirmal singh Mehta
Greenhorn

Joined: Sep 08, 2012
Posts: 6
JSP::

<select id="form_city" name="form" onchange=''return filterChange();''>
<option value="All">View All</option>
<option value="1">General</option>
<option value="0">Proposed</option>
</select>

function filterChange(){

document.forms["form"].submit();

}


In the front end, irrespective of what i have selected in the dropdown, it always takes "All" as selected and when submit the form "All" value goes to action every time. Please help
john Dalton
Greenhorn

Joined: Jun 18, 2012
Posts: 12
Before submit button write a script to set a value to ALL and then submit the form in next line by submit.form();
Nirmal singh Mehta
Greenhorn

Joined: Sep 08, 2012
Posts: 6
This is already happening from my current code and i want only the selected from the dropdown to go to my action class. Please help
Ankit Dan
Ranch Hand

Joined: Aug 31, 2012
Posts: 47

You can use some jquery inside the on change event



hope this helps
 
 
subject: Dropdown always selects the first value
 
Similar Threads
assign dropdown selected value to a java variable
Selecting option in second selectOneMenu not setting property value
Retain option selected value on submit
Dropdown Selected returning unexpected value on submit.
Unable to retain Dropn down values after submitting form