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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:50:06+00:00 2026-05-27T13:50:06+00:00

I am having an issue with the change function in jQuery 1.7.1 and postbacks.

  • 0

I am having an issue with the change function in jQuery 1.7.1 and postbacks. Basically I need to toggle the disabled attribute of buttons depending on whether an item is selected in the dropdown. In the code I have:

<input type="button" id="btnRed" value="show Red" disabled="disabled" class="spButton" />
<input type="button" id="btnBlue" value="show Blue"   disabled="disabled" class="spButton"/>
<input type="button" id="btnYellow" value="show Yellow" disabled="disabled"  class="spButton" />

I have my asp dropdown with autopostback set to true

<asp:DropDownList ID="selAccount" runat="server"  
    onselectedindexchanged="selAccount_SelectedIndexChanged" AutoPostBack="true">
    <asp:ListItem Value="-1">select me</asp:ListItem>
    <asp:ListItem Value="234">234</asp:ListItem>
</asp:DropDownList>

and the jQuery:

 $(document).ready(function () {
    $("#selAccount").change(function () {
        var selValue = $(this).val();

        if (selValue == '-1') {
            $(".spButton").attr("disabled", "disabled");
        }
        else {
            $(".spButton").removeAttr("disabled");
        }
    });
 });

invariably, when postback occurs, the buttons remain disabled. I tested with an enabled button and it is firing twice. i have tried different approaches (bin, unbind) to no avail. I got around this issue with a hidden variable set on the SelectedIndexChanged in code-behind and interrogating the hidden variable value in jQuery. is there an issue with the change method? is there a better way to do this? any insight would be appreciated. thanks,

  • 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-27T13:50:07+00:00Added an answer on May 27, 2026 at 1:50 pm

    If you are doing a postback each time the value is changed, then the page is reloaded and the changes made by jQuery are lost..

    Either stop the auto-postback (set it to false), or if required change your code from the change event to the ready event..

    $(function(){
        var selValue = $("#selAccount").val();
    
        if (selValue == '-1') {
            $(".spButton").attr("disabled", "disabled");
        }
        else {
            $(".spButton").removeAttr("disabled");
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a bit of an issue solving a jQuery form problem. Basically I
I'm having an issue regarding some jQuery I am using to highlight a menu
I am having an issue with jquery tools / scrollable plugin. Using the circular:true
I'm having a serious issue with Internet Explorer caching results from a JQuery Ajax
I'm having a strange issue with counting form elements in jQuery. While I can
I'm having an issue calling a javascript function within a Google Maps InfoWindow. The
Here's an issue I'm having with the .ajaxForm() method of the jQuery Form Plugin
i am having trouble. i write HTML and jQuery and set same name attribute
The Solution: http://noteslog.com/post/how-to-fix-the-resize-event-in-ie/ Development Issue: I am having an IE7 compatibility issue with jQuery.
I'm having trouble to get a font increase/decrease jquery function done. It has 3

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.