/    Sign up×
Community /Pin to ProfileBookmark

selection of combo box in jsp

Hello Techies,
I had created two combo boxes. After selection of first combo box the values are populated into second combo box.
But the problem is I am loosing the value which i selected in first combo box.
How can I get the value in the first combo box??
I tried with the following code.

<script language=”javascript”>

function selectApplication() {
alert(‘hi’);
var index = document.forms[0].applications.selectedIndex;
alert(index);
document.forms[0].hiddenName.value = index;
document.forms[0].submit();
}
function selectRuleSet() {
var index = document.forms[0].ruleSet.selectedIndex;
document.forms[0].hiddenName.value = index;
document.forms[0].submit();
}

function setSelectedComboIndex(){
alert(“seltSeletedComboIndex”);
var index = ‘<%request.getParameter(“hiddenName”);%>’;
alert(index);
document.forms[0].comboboxName.selectedIndex =index;

}
</script>

Here is jsp code.
<select name=”applications” >
<option value=””>application
<%
while(it.hasNext())
{
String applicationName = it.next().toString();

%>
<option value=”<%= applicationName %>”> <%= applicationName %>

<% } %>

</select>
<input type=”submit” onClick =”selectApplication()”>

Here setSelectedComboIndex() is not returning no value. I

can u guys tell what xactly I am missing.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceJun 16.2006 — If you're populating the second SELECT via server-side code, then it is the responsibility of the same server-side code to maintain the current selection in the first SELECT. This merely entails the server-side code dynamically inserting an appropriate [b]selected[/b] attribute into the proper OPTION tag.
×

Success!

Help @ksrk31 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...