1

I have HTML like this :

<li class="MostViewedProducts">
    <input class="MostViewedProductsi" type="checkbox" checked="checked"/>
    <span class="labels">Some Text</span>
    <a class="fancybox" href="#inline40" id="tozih"></a>
</li>

and some Jquery like this :

$('.MostViewedProductsi').attr('disabled', true);
var $form = $('*');

My Question is :

When I Disable the Class , the Jquery can't read the element and pass it by GET or POST to the PHP file, and when I make the class -MostViewedProducts- read only , the user can still change the check box.

What solution can I use ?

3 Answers3

2

This is by design of HTML - no disabled elements are passed in a GET or POST.

To remedy this you could remove the disabled attribute on submission of the form so that the elements' value can be posted.

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
  • @gdoron true, but he also says 'jQuery can't pass it' implying some kind of POST is being made. I'll leave this answer until the OP clarifies what he's trying to do. – Rory McCrossan Oct 24 '12 at 07:49
  • This is the sloution witch i want , excuse me for my lake of description , i edit the question to be more understandable . thanks. –  Oct 24 '12 at 08:03
  • @RezaMarefaty. It still doesn't too much sense, as jQuery CAN read disabled elements. Glad Rory could help you. +1. – gdoron Oct 24 '12 at 08:16
1

Two options:

$('.MostViewedProductsi').attr('disabled', 'disabled');
$('.MostViewedProductsi').prop('disabled', true); // jQuery version 1.6+
gdoron
  • 147,333
  • 58
  • 291
  • 367
0

You use wrong value of attribute disabled see here for more information:

HTML <input> disabled Attribute

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Anton Baksheiev
  • 2,211
  • 2
  • 14
  • 15