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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:55:41+00:00 2026-05-27T03:55:41+00:00

The way I usually implement a select box is: <select size=1 name=example_length onchange=callSomeMethod> <option

  • 0

The way I usually implement a select box is:

 <select size="1" name="example_length" onchange="callSomeMethod">
    <option value="10" selected="selected">10</option>
    <option value="25">25</option>
    <option value="50">50</option>
    <option value="100">100</option>
  </select>

I have attached an action on onclick event

There is another way check the dropdown source here

  <select size="1" name="example_length">
    <option value="10" selected="selected">10</option>
    <option value="25">25</option>
    <option value="50">50</option>
    <option value="100">100</option>
  </select>

In the second implementation it’s unclear what action is registered on the onchange event

Question: in second implementation we usually use some Javascript library to register the actions, but I feel that with the first implementation was clear, readable and easier to debug, whereas second implementation is bit puzzling to me, so, why do we use second approach and how to debug this?

Any link regarding this will be much appreciated.

  • 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-27T03:55:41+00:00Added an answer on May 27, 2026 at 3:55 am

    I find it clearer to keep my code separate from my HTML mark up. This is especially true when the handlers are applied to multiple elements on the page. It makes for a cleaner implementation when I can go to a single place in the code — which may be included from a script that can be reused with several pages — and make a change, than to have to search throughout the code and make changes to, perhaps, many individual elements to reflect a small change in a function.

    Further, I think it makes it easier to debug the code when it’s not interspersed with the mark up. Using Firebug or IE Developer tools, you can set break points in the javascript code, inspecting values and stepping through the code to find any errors. At the other extreme, putting an entire function into a markup-applied click handler makes it basically impossible to debug. You’ve already taken one step toward easing that by introducing a separate function that is called. Applying the handler via code improves this by allowing the application of that handler function to be debugged as well.

    Another benefit, and this is subtle, is that applying the handlers separately forces you to use better semantics and naming conventions than otherwise. One drawback, as you’ve seen, is that when the code is inline, it’s easier to see what handlers are being applied by inspection. When applying them via code, you have to use better semantics, decorating the affected elements with meaningful class names, using good, descriptive element and function names, and refactoring back to reusable code components (to take full advantage). This seeming disadvantage, actually helps to force you to write better, more maintainable markup and javascript.

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

Sidebar

Related Questions

When I run an MSI (without parameters) I usually have to click my way
Why should I use #' together with lambda? It is usually written that way,
Is there any way to use Dropbox to sync selected local files? I like
Can you please help me answer the following questions? How do people usually implement
Has anyone been able to create of find an open source way to implement
I'm attempting to implement this paper . I've have most of it down, but
Basically, something better than this: <input type=file name=myfile size=50> First of all, the browse
Usually I'm using One-to-many relationship by this way : class Study { static hasMany
a while ago, i asked about how to implement a REST api. i have
In my asp.net-mvc website I have a field that usually has a string (from

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.