Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1033677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:16:04+00:00 2026-05-16T14:16:04+00:00

The pasted below code i am using to create dropdown list and java script

  • 0

The pasted below code i am using to create dropdown list and java script for doing some stuffs

<td>
  <select id="currentCustomer" onchange="showSelectedCustomer(this)">
  <c:forEach var="Customer" items="${listCustomer}" >
      <option value="<c:out value="${Customer}" />"><c:out value="${Customer}" />
      </option>
 </c:forEach>
  </select>
</td>

function showSelectedCustomer(dropdown) {
var selectedCustomer = dropdown.options[dropdown.selectedIndex].value;
var currentCustomer = document.getElementById('currentCustomer');

 var context = document.forms[0].context.value;
document.forms[0].mode.value = "UPDATE";
document.forms[0].custName.value = dropdown.options[dropdown.selectedIndex].value;
document.forms[0].action=context+"/updateReportDetail.do";
document.forms[0].method="POST";
document.forms[0].submit();
}

My problem is
how to set the onselected value dynamically in drop down list.

Let me explain briefly here,

Initially at the time of logging application the landing “x.JSP” page will display drop down list with multiple customer names with first customer name as selected one by default.
If i select other customer name in drop down list i am calling Javascript[onchage event] to submitting to form and to do some other stuffs in DAO java class for the selected customer and returning back to “x.JSP” page.

Now the thing is i need to set the latest customer name [ie..the customer i processed in DAO java class] as onselected one in the drop down list.

Help me guys.Thanks for your effort in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:16:05+00:00Added an answer on May 16, 2026 at 2:16 pm

    In your forEach loop, check if the Customer in your current iteration is the one that matches your predetermined choice. You don’t give any indication of how you’re choosing the “right” customer to be selected when the page loads, so I’ll use some pseudo-code for that.

    <c:forEach var="Customer" items="${listCustomer}" >
       <%  String selected = "";  
           if (customer.equals(predeterminedCustomerToBeSelected)) {
               selected = "selected"; }
       %>
          <option value="<c:out value="${Customer}" />" <%=selected%>><c:out value="${Customer}" />
          </option>
     </c:forEach>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 508k
  • Answers 508k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Well, it is possible but quite awkward. The problem is… May 16, 2026 at 4:17 pm
  • Editorial Team
    Editorial Team added an answer As with all DBMS optimisation questions, it depends on your… May 16, 2026 at 4:17 pm
  • Editorial Team
    Editorial Team added an answer Dont save them to the camera album first. I dont… May 16, 2026 at 4:17 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a plot (sample code pasted below) that I am trying to add
I am using the class pasted below to listen for the keypress event ctrl
I'm having problems with some code to create a CDialog based window. The code
I am using the code below to do pagination on a table (please do
I've created a simple parameterless stored procedure which I've pasted below. I've imported the
This error message is driving me nuts. I'm getting it when using Html.ListBox and
I am attempting to create a small application to collect data received from an
I have taken an example straight out of the MSDN. I want to create
I have a JQuery (using JQuery 1.4.2) problem that exhibits only in IE8 in
I have a Drupal view which should output a video player using flash. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.