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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:08:26+00:00 2026-05-11T16:08:26+00:00

I have a SELECT element which adds its value to a hidden INPUT via

  • 0

I have a SELECT element which adds its value to a hidden INPUT via JavaScript every time an OPTION is clicked (along with a visual representation of each selection) and I’d like to be able to monitor changes for another JavaScript function. For the sake of modularity, I can’t integrate the second function into the first one. I would also rather not poll the hidden INPUT’s value to avoid hacks. Currently I am using the onclick event on the DIV that contains both the SELECT and the hidden INPUT, but that’s also quite hack-ish. Do you know a way to monitor a hidden INPUT element for changes?

  • 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-11T16:08:27+00:00Added an answer on May 11, 2026 at 4:08 pm

    So, you have:

    • Function A, which updates the hidden INPUT.
    • Function B, which should be called when the INPUT is updated.

    Why not create an “event” of your own that that function A calls/dispatches whenever it is done working?

    I believe most Javascript frameworks support the concept of custom events pretty easily, but it’s just a series of function calls.

    For example, create some object D which represents the dispatcher for a single event. Yes this is silly, but I’m trying to keep the concept simple. This object D, holds a list of functions which have “registered” for its event, and when the event is dispatched, it calls those functions.

    Something like:

    var d = (function() {
        var funcs = [];
    
        function fire() {
            for (var i=0; i<funcs.length; ++i) {
              funcs[i].call();
            }
        }
    
        function register(newfunc) {
            funcs.push(newfunc);
        }    
    
        return {
            fire: fire,
            register: register
        };
    })();
    

    You just have two things left to do – make function A fire the event:

    function A() {
    
        // do stuff to update the INPUT
    
        d.fire();
    }
    

    and also, onload, “register” function B to be called when the event happens:

    d.register(B);
    

    This approach maintains the seperation-of-modules principle (or whatever its called) since A and B know nothing of each other, and only need to know about a third object.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I found the problem. It's very subtle. The selector for… May 11, 2026 at 7:35 pm
  • Editorial Team
    Editorial Team added an answer In the dropdown menu, Format->Conditional formatting... Then set your rules… May 11, 2026 at 7:35 pm
  • Editorial Team
    Editorial Team added an answer While I haven't made that particular conversion, I have gone… May 11, 2026 at 7:35 pm

Related Questions

I have a select control, and in a javascript variable I have a text
I'm creating a custom Java Struts tag that is for building and formatting an
In SQL Server I have a DATETIME column which includes a time element. Example:
I have a bunch of dropdownlists which I populate from an xml file using
I have a list called 'optionlist' which may change length from day to day,

Trending Tags

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

Top Members

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.