tags:

views:

53

answers:

3

Hello friends I am using this code in my view..

Using this code I am disabling the fields when the view loads.. like this my view displyas for number of users which I am going to selct using this below code I am able to disable only first Fiedset not for other fieldsets?

why its happening? I need to disable for how many users I select....

thanks..

+1  A: 

If you want to disable those input elements for all fieldsets:

$("fieldset").find("input, select, textarea").attr('disabled', 'disabled');

The selector you are using (#Fieldset1) does not seem to reference any part of your markup. What it means is "select me the element whose id is Fieldset1". Since that element does not exists, nothing happens. You should read into the correct syntax and usage of jQuery selectors.

Also, you can use the :input selector to substitute for all types of form input elements:

$("fieldset :input").attr('disabled', 'disabled');
karim79
karim thanks, this is my fieldset id PricingEditExceptionsi am using somethig like this $("#PricingEditExceptions").find("input, select, textarea").attr('disabled', 'disabled'); this is doing for only one fieldset do i need to take # out? from the code?
kumar
@kumar - Do you have *multiple* `<fieldset id="PricingEditExceptions">`, with the same ID?
Nick Craver
no only one i have but this fieldset is excecuting multiple times depends on selection to display exceptions..
kumar
+1  A: 

This line:

$("#PricingEditExceptions")
     .find("input, select,textarea")
     .attr('disabled', 'disabled');

is placed above where the html is. It will execute before the html you wish to disable is in the dom. Also, if this is in a control that could be on the page more than once, it is not technically valid to have multiple html elements with the same id.

I would first, move your line to disable code into your $(document).ready function block. Then consider using a class name instead of an id for "PricingEditExceptions".

Hope this helps.

jhorback
this is diabling only first time.. what happend if the view is again execting this code its not working for me
kumar
+1  A: 

Not sure I understand your question 100%, but I think you're problem is in the selector part of your jQuery-code: $("#Fieldset1") will apply your actions on only the DOM-element which has an ID of Fieldset1, if you want to disable all fieldsets $("Fieldset") will instead select all fieldsets.

I'm however guessing you want to disable a subset of fieldsets based on some data - given I don't know the data you're basing this decision on I would recommend a visit to see if you can find something in common for all the DOM elements you wish to select: http://api.jquery.com/category/selectors/

nillls
is there any way that i can disable the fieldset without having this id?that is i have one filedset with id="student"other fieldset id"class"' these are more then one filedsets having..if i use this code $("Fieldset") its hides all the fieldsets including student id.. i need to disbaled ony class id fieldset?thanks
kumar