wood burning stoves 2.0*
The moose likes Struts and the fly likes setting a default item in a dynamic dropdown list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "setting a default item in a dynamic dropdown list" Watch "setting a default item in a dynamic dropdown list" New topic
Author

setting a default item in a dynamic dropdown list

Vijaya Parvathaneni
Greenhorn

Joined: Nov 29, 2012
Posts: 3
Hi All,
I have a requirement to set a default item in the dropdown based on some conditions.

I have the value to be set as default in
document.getElementById('defaultBenLevel');

I have my select as below
<form:select path="selBenefitLevel" id="selBenefitLevel" cssClass="selectOneListBox" tabindex="1">
<formptions items="${viBenefitsForm.benefitLevelLst}" itemValue="label" itemLabel="value" />
</form:select>

In my javascript, I am trying to do this

var defaultBenLevel = document.getElementById('defaultBenLevel').value;
document.getElementById('selBenefitLevel').value = defaultBenLevel;

But still I am not able to set the default value as selected. Please help..

Thanks in advance... any help would be highly appreciable..
Karthik Jayachandran
Ranch Hand

Joined: Feb 18, 2009
Posts: 88

Are you trying to set value to a combo box from another combo box? This link might help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setting a default item in a dynamic dropdown list
 
Similar Threads
Dynamic tabIndex
Dropdown Selected returning unexpected value on submit.
JSTL for loop
Dynamic AJAX control
Spring AJAX problem