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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:46:04+00:00 2026-06-11T07:46:04+00:00

I am trying to enable/disable some hidden fields based on some calculation and using

  • 0

I am trying to enable/disable some hidden fields based on some calculation and using jquery
prop function, here is the code

function enableSelectedFieldsData(count, mapKey, index) {
    $("#code_" + mapKey + "_" + index).prop("disabled", false);
    $("#description_" + mapKey + "_" + index).prop("disabled", false);
    $("#crossRefrence_" + mapKey + "_" + index).prop("disabled", false);
    $("#image_" + mapKey + "_" + index).prop("disabled", false);
    $("#price_" + mapKey + "_" + index).prop("disabled", false);
    // disable all other fields
    for (var i = 0; i < count; i++) {
        if (i != index) {
            $("#code_" + mapKey + "_" + i).prop("disabled", true);
            $("#description_" + mapKey + "_" + i).prop("disabled", true);
            $("#crossRefrence_" + mapKey + "_" + i).prop("disabled", true);
            $("#image_" + mapKey + "_" + i).prop("disabled", true);
            $("#price_" + mapKey + "_" + i).prop("disabled", true);
        }
    }
}

Initially i am setting disable=true for all fields and based on the selection i m trying to enable selected fields while disabling other fields, since as per my knowledge disable fields never got submitted to the server on submitting the form, but in my case they are getting submitted.

on checking using firebug i saw that the disable field value for non selected item is getting set as "" like disable=""

i am not sure where i am setting things wrong, any help or pointer in this regard will really be helpful.

Edit

I have taken out the relevant section from my generated HTML and placed it at jsfiddle
please have a look

  • 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-06-11T07:46:06+00:00Added an answer on June 11, 2026 at 7:46 am

    Do you have prop() available?

    prop() was added in jQuery 1.6 and is used like this:

    $("input").prop('disabled', true);
    $("input").prop('disabled', false);
    

    If you are using jQuery 1.5.x or lower you can use attr() instead as seen in this FAQ – How to enable/disable form elements from the jQuery site:

    // Disable #x
    $('#x').attr('disabled', true);
    
    // Enable #x
    $('#x').attr('disabled', false);
    
    // -- or --
    
    // Disable #x
    $("#x").attr('disabled', 'disabled');
    
    // Enable #x
    $("#x").removeAttr('disabled');
    

    Assuming you are using jQuery 1.6 or higher

    Your syntax looks fine.
    I would guess your problem is then most likely incorrect selectors.

    To validate the selector contains the element reference you expect do:

     // output the selector to the console
    console.log($("#code_" + mapKey + "_" + index));
    

    If you see an element in your browser’s debugging console you are looking at a valid selector, if instead you see [] the your selector is invalid.

    Alternatively you can check it using the length property and alert that out:

    // alert out the length of the jQuery selector
    alert($("#code_" + mapKey + "_" + index).length);
    

    If you see 0 then your selector is invalid, if you see 1 or more then your selector is correct.

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

Sidebar

Related Questions

I'm trying to disable/enable controls based on user permission using a custom security framework
I' m trying to enable adding/deleting rows to/from table using folowing code: Script: $(document).ready(function()
I'm attempting several methods trying to enable/disable Wi-Fi (toggle). Here are some things I
I'm trying to simply enable/disable a button based on whether a value has been
I'm trying to come up with a solution to programmatically enable/disable the network card
I'm trying to use MultiDataTriggers to enabled/disable a button based on the value of
I am trying to make some small additions to some old java code that
I'm trying to port some OpenGL rendering code I wrote for iOS to a
Possible Duplicate: What does jQuery.fn mean? I have some script on a page trying
Im using Visual Studio 2010 Ultimate and Im trying to convert some images using

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.