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 8145449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:39:55+00:00 2026-06-06T13:39:55+00:00

I have a drop down menu which fills with some doc names. Now when

  • 0

I have a drop down menu which fills with some doc names. Now when a person selects a document it calls onDocumentChange() method.

To fill the drop down menu i receive a object called result which is a list of doc objects from server.

<select id="documentSelect" onChange="onDocumentChange()">
<c:forEach items="${results}" var="result">
    <option id="${result.getDocDisplayURL()}"><c:out value="${result.getDocFn()}"/></option>
</c:forEach>
</select>

Till this point it is strainght forward.

Now this doc object has some other attributes called date and time. Now when the user clicks any item from drop down menu i want to send that particular items time and date attributes to onDocumentChange() method. How can i do that.

I am guessing something like this

<select id="documentSelect" onChange="**onDocumentChange(result.date, result.time)**">
<c:forEach items="${results}" var="result">
<option id="${result.getDoc()}"><c:out value="${result.getText()}"/></option>
</c:forEach>
</select>

Thanks

  • 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-06-06T13:39:56+00:00Added an answer on June 6, 2026 at 1:39 pm

    You seem to be thinking that JavaScript runs together with Java/JSP. This is untrue. Java/JSP produces HTML and JavaScript is part of that HTML and works on the HTML DOM tree only. You need to make sure that your Java/JSP code produces HTML code containing exactly the information JavaScript needs to access. You can let Java/JSP print those variables as an attribute of a HTML element, like <option> in your case. You can use custom data-* attributes in HTML to append custom attributes.

    <option value="${result.doc}" data-date="${result.date}" data-time="${result.time}">
    

    You can get the currently selected <option> element in JavaScript as follows

    var option = select.options[select.selectedIndex];
    var doc = option.value;
    var date = option.getAttribute("data-date");
    var time = option.getAttribute("data-time");
    // ...
    

    You only need to change the onchange handler to pass the HTML <select> element itself

    onchange="onDocumentChange(this)"
    

    with

    function onDocumentChange(select) {
        // ...
    }
    

    By the way, why are you using separate properties for date and time instead of a single java.util.Date property? There’s something wrong in the model design.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a drop down navigation menu in which some of the title should
I have a drop down menu made with Jquery. Right now, if you hover
I have a drop down menu of mobile brands. When a user selects a
i have built jQuery drop-down menu which is having problems floating over the UI
I have a drop down menu which I found a tutorial for. In Firefox
I have got a drop down menu which works fine but i want to
I have 2 div tags which emulate a drop-down menu. When the outer div
I have jFrame class MainForm which contains main() , placePanel(panel) and drop down menu.
I have a JQuery drop down menu which has animated when we hover the
I have number of drop down menu's which gets called with a onClick event

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.