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

  • Home
  • SEARCH
  • 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 1007133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:34:16+00:00 2026-05-16T08:34:16+00:00

How to use onClick() or onSelect() with option tag? Below is my code in

  • 0

How to use onClick() or onSelect() with option tag? Below is my code in which I tried to implement that, but it is not working as expected.

Note: where listCustomer domain object list getting in JSP page.

<td align="right"> 
  <select name="singleSelect" "> 
     <c:forEach var="Customer" items="${listCustomer}" >
     <option value="" onClick="javascript:onSelect(this);> <c:out value="${Customer}" /></option>
                </c:forEach>
          </select>         
        </td>   

How do I modify it to detect that an option is selected?

  • 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-16T08:34:16+00:00Added an answer on May 16, 2026 at 8:34 am

    Neither the onSelect() nor onClick() events are supported by the <option> tag. The former refers to selecting text (i.e. by clicking + dragging across a text field) so can only be used with the <text> and <textarea> tags. The onClick() event can be used with <select> tags – however, you probably are looking for functionality where it would be best to use the onChange() event, not onClick().

    Furthermore, by the look of your <c:...> tags, you are also trying to use JSP syntax in a plain HTML document. That’s just… incorrect.

    In response to your comment to this answer – I can barely understand it. However, it sounds like what you want to do is get the value of the <option> tag that the user has just selected whenever they select one. In that case, you want to have something like:

    <html>
     <head>
      <script type="text/javascript">
    
       function changeFunc() {
        var selectBox = document.getElementById("selectBox");
        var selectedValue = selectBox.options[selectBox.selectedIndex].value;
        alert(selectedValue);
       }
    
      </script>
     </head>
     <body>
      <select id="selectBox" onchange="changeFunc();">
       <option value="1">Option #1</option>
       <option value="2">Option #2</option>
      </select>
     </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating composite control, which has two other components that rely on each other.
I use event delegation in such way: elWraper.onclick = (function(){ //how to get here
<div>'.$i.'</div> $i is auto generated by loop - which could lead to: <div>'.$i.'</div> <div>'.$i.'</div>
So there are 4 main methods I'm aware of to execute javascript code from
I have a referral project. In that there is an agent between the affiliate
I am having problems getting a function that clicks all search matched checkboxes. The
I'm dynamically generating datepicker's by simply appending the field HTML to a div: <input
From my experience I know three different ways to execute a JavaScript function when
I need to do some server side logic on a row in my repeater

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.