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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:40:39+00:00 2026-05-23T18:40:39+00:00

I have a onclick attribute ontag now that gets set serverside with the REQUIRED_ID

  • 0

I have a onclick attribute ontag now that gets set serverside with the REQUIRED_ID for when the user clicks on it.
The problem now is that I am trying a more jQuery-like approach where I do set the click handlers on document ready but now I don’t have the REQUIRED_ID at hand to set it.
I’m wondering what would be the jQuery way of doing this, perhaps setting another tag with the REQUIRED_ID and reading it on ready?

NOW:

$.ready(
    $('select.attr_satus>option:not(:selected)').each( 
        /* I AM MISSING REQUIRED_ID, WHERE DO I GET THIS VVVVVV*/
        $(this).click(function(){ statusChanged(this,REQUIRED_ID,$(this).val()); }) 
    );
);

BEFORE:

<select class="attr_status">
<option onClick='statusChanged(this,REQUIRED_ID,"draft");' value='draft'>Draft</option>
<option value='publish' selected="true">Published</option>
</select>

REQUIRED_ID is an id that changes per row, as I have several of those select tags one after each other.

  • 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-23T18:40:40+00:00Added an answer on May 23, 2026 at 6:40 pm

    You can store your extra information in “data-” attributes:

    <select class="attr_status">
      <option  data-requiredId='REQUIRED_ID' value='draft'>Draft</option>
    

    Then in your event handler you can get it with “.data()”:

    $(this).click(function() {
      statusChanged(this, $(this).data('requiredId'), this.value);
    });
    

    edit — Now “data-” attributes are standardized with HTML5. Another approach is to use the “class” string, which can contain pretty much anything. What I’ve done is use a “name:value” notation:

    <select class="attr_status">
      <option  class='requiredId:REQUIRED_ID' value='draft'>Draft</option>
    

    Then in the handler:

    $(this).click(function() {
      var id = this.className.replace(/^.*\brequiredId:(\S+).*/, '$1');
      statusChanged(this, id, this.value);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some buttons with an onclick attribute and some that don't. I want
I have some HTML with an onclick attribute. I want to override that attribute
In my layout xml file I have set the android:onClick attribute for a Button
I have an internal website that has a link with NO onClick attribute present.
I have a WebBrowser control and try to set onclick and href attributes on
I have an update panel on my page with some links that have onClick
I have a onclick event that is like: public void OnMyButton_Click(object sender, EventArgs e)
I have an onclick function that I want to add an anchor to the
Unobtrusive JS suggests that we don't have any onclick attributes in our HTML templates.
I have a program that places input buttons on a form. When a user

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.