2013-09-28 5 views
0

У меня есть форма, как это и мне нужно, чтобы представить все значения в этой форме, за исключением тех, с класса = «NoDisplay». Передайте его контроллеру и обновите значение до «pd-price». Все работает отлично, просто я не могу найти способ игнорировать значения noDisplay для отправки формы.JQuery Ajax: отправить выбранные значения из формы

 <div class="cart"> 
         <strong> 
          <span class="pd-price">80.407.000đ</span> 
         </strong> 

     </div>  


    <form method="post" id="product-details-form" action="xxx"> 
     <ul> 
    <li class="showImg-target noDisplay"> 
     <input type="radio" name="product_attribute_46_3_113"> [+3.870.000] 
    </li> 
    <li class="showImgtarget"> 
<input type="radio" name="product_attribute_46_4_113">[+1.000.000]</li> 

    <li class="showImgtarget noDisplay"> 
<input type="radio" name="product_attribute_46_5_113">[-1.500.000]</li> 
    <li class="showImgtarget noDisplay"> 
<input type="radio" name="product_attribute_46_6_113"></li> 

          ..... a lot more 

            </ul> 
         </form> 


<script type="text/javascript"> 
     $(function() { 
     updateStatus(); 
     $('*[name^=product_attribute]').change(function() { 
     updateStatus(); 
     }); 

     function updateStatus() { 
     $.ajax({ 
        cache: false, 
        url: '/Catalog/UpdateProductStatus', 
        data: $('#product-details-form').serialize(), 
       type: 'post', 
       success: function (data) { 
       $('.summary-info').html(data.View); 
       $('.pd-price').html(data.Price); 
        $('.powered-icon').replaceWith(data.Pictures); 
         } 
              }); 
             } 
            }); 
           </script> 
+1

http://stackoverflow.com/questions/4556172/excluding-certain-inputs-on-serialize выглядит то, что вам нужно? – Victor

+0

спасибо, это интересно. –

ответ

1

Вы можете использовать :not() селектор:

$('#product-details-form li:not(.noDisplay) :input').serialize(); 
Смежные вопросы