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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:39:18+00:00 2026-05-13T12:39:18+00:00

I have a radio button, containing an inline onclick event: <input type="radio" class="quantitycheckbox" onclick="alterQuantity(this.form)">

  • 0

I have a radio button, containing an inline onclick event:

<input type="radio" class="quantitycheckbox" onclick="alterQuantity(this.form)">

I’m trying to unobtrusively add some more functionality on click, and have this code:

function updateCustomFields( box ) {
    // save current onclick event before assigning new one
    var currEvent = box.onclick;
    box.onclick = function() {
        currEvent();
        // do additional stuff here
    }
}

var boxes = $class('quantitycheckbox');
for( var i = 0; i < boxes.length; i++ ) {
    updateCustomFields( boxes[i] );
}

However, the value of this.form that’s passed into the alterQuantity function is undefined, and I get an error. How would I preserve the onclick event as it is and add my functionality?

  • 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-13T12:39:19+00:00Added an answer on May 13, 2026 at 12:39 pm

    You don’t need to do anything with the inline onclick event. Simply by attaching another event using attachEvent or addEventListener will solve your problem since the inline onclick event will always fire first:

    function updateCustomFields( box ) {
        var myCallback = function(){
          // Do stuff here
        }
        if(window.addEventListener){
          box.addEventListener('click', myCallback, false);
        } else if (window.attachEvent){
          box.attachEvent('onclick', myCallback);
        }
    }
    

    The execution order will be:

    1. Inline event
    2. Your new event
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This one's really kicking my backside. I have a form, spawned and owned by
I know xcode don't have radio Button so I try to add a custom
Is it possible to have a Radio button list, like we have a checked
I trying to make a simple image gallery, where I have several radio button
I'm dynamically pulling and displaying radio button quesitons on a form (separated into different
I previously posted this question as jquery/javascript: arrays - jquery/javascript: arrays . But since
I have a problem to find the right way to program dynamic fields. For
The app I am trying to make needs a few info in the beggining,
on my site project I want the user to be able to change the
I've got a question regarding sub forms. Currently I've got 2 sub forms and

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.