通过使用此组件,检索父类数据

时间:2016-04-28 05:57:19

标签: javascript

onChange事件中,我使用 this (即)validateCommuteDate($(this))调用了新功能。我可以获得该课程的价值。但是我如何获得另一个类值?

我的HTML数据是:

<div class="inner-row" id="pension-transaction-row-3" data-pension-row-id="3" style="margin-top: -6px; margin-bottom: -6px;">
   <div class="col-sm-1" style="width:3%;padding-top:32px; "><span id="pensionName_3"></span></div>
   <div class="col-sm-3 showError for-transaction-type-3">
       <label class="mobile-label visible-xs">Transaction</label>
       <label class="mobile-label hidden-xs">&nbsp;</label>
       <select name="data[ClientLimeSmsfActuarialFormsMembersOneOffTransactionPension][3][transaction_type_id]" class="form-control pensionTransactionType" id="pension_transaction_type_3" style="padding:6px 6px;">
           <option value="">-- Select --</option>
           <option value="commence">Pension Commencement</option>
       </select>
   </div>
   <div class="col-sm-8 has-deleticon">
       <div class="col-sm-3 showError for-pension-transaction-date-3">
           <label class="mobile-label visible-xs">Date</label>
           <label class="mobile-label hidden-xs">&nbsp;</label>
           <input name="data[ClientLimeSmsfActuarialFormsMembersOneOffTransactionPension][3][transaction_date]" class="form-control date-wheel-select transaction-date-wheel tdate" id="pension_transaction_date_3" placeholder="Date (DD/MM/YYYY)" style="padding:6px 6px;" value="01/06/2015" type="text"></div>

       <div class="col-sm-5">
           <label class="mobile-label visible-xs">Amount</label>
           <div class="showError for-pension-transaction-amount-type-3 col-sm-12" style="display: block;">
               <label class="mobile-label hidden-xs">&nbsp;</label>
                   <div class="">
                       <select name="data[ClientLimeSmsfActuarialFormsMembersOneOffTransactionPension][3][pension_amount_type]" id="pension_amount_type_3" class="form-control pensionAmountType" style="padding: 6px 5px;">
                       <option value="">-- Select --</option>
                       <option value="1" selected="selected">Entire Balance</option>
                       <option value="2">Specific Amount</option>
                       </select>
                   </div>
           </div>
           <div class="col-sm-6 showError for-pension-transaction-amount-3" style="display: none;">
           <label class="mobile-label hidden-xs">&nbsp;</label>
               <div class="input-group input-group-small">
               <span class="input-group-addon">$</span>
               <input name="data[ClientLimeSmsfActuarialFormsMembersOneOffTransactionPension][3][transaction_amount]" class="form-control pensionTransactionAmount text-right" style="padding:6px 6px;" value="0" type="text" id="ClientLimeSmsfActuarialFormsMembersOneOffTransactionPension3TransactionAmount" placeholder="Amount">                                </div>
           </div>
       </div>

       <div class="col-sm-4" id="columnLabels-3">
           <div class="col-sm-6 columnMemberOne showError for-pension-transaction-member-1-3" style="padding-right:1px;">

               <label class="mobile-label columnLabelOne" style="display: none;">Deceased Member</label>
               <label class="mobile-label columnLabelhidden Onehidden-xs">&nbsp;</label>
               <select name="data[ClientLimeSmsfActuarialFormsMembersOneOffTransactionPension][3][member_1]" class="form-control memberOne form-control-sm member12" id="member_1_3">
               <option value="">-- Select --</option>
               <option value="1" selected="selected">Adam</option>
               <option value="2">Betty</option>
               </select>
           </div>


           <div class="col-sm-6 columnMemberTwo showError for-pension-transaction-member-2-3" style="padding-left: 6px; display: none;">
               <label class="mobile-label columnLabelTwo" style="display: none;">Receiving Member</label>
               <select name="data[ClientLimeSmsfActuarialFormsMembersOneOffTransactionPension][3][member_2]" class="form-control memberTwo form-control-sm" id="member_2_3">
                   <option value="">-- Select --</option>
                   <option value="1">Adam</option>
                   <option value="2">Betty</option>
                   </select>
               </div>

           <div class="col-sm-6 showError for-pensionCommutationNumber-3">
               <label class="mobile-label columnLabelOne" style="display: none;">Deceased Member</label>
               <label class="mobile-label columnLabelhidden Onehidden-xs">&nbsp;</label>

               <select name="data[ClientLimeSmsfActuarialFormsMembersOneOffTransactionPension][3][pension_commutation_number]" class="form-control pensionCommutationNumber" id="pensionCommutationNumber_3"><option value="0" selected="selected">--Select--</option><option value="1A">1A</option><option value="1B">1B</option></select>                            </div>
           </div>
           <button class="btn-delete pensionCloneRemove" data-pension-div-id="3" style="top: 24px;"><i class="fa fa-trash-o"></i></button>
       </div>
   </div>

OnChange事件中:

$(document).on('change', '.tdate', function(){
    validateCommuteDate($(this));
});

ValidateCommuteDate功能:

 function validateCommuteDate($this){
     var a = $this.val();
 }

如何检索pensionCommutationNumber值和pensionTransactionType值?

1 个答案:

答案 0 :(得分:0)

function validateCommuteDate($this){
     var row_id = $this.parents('.inner-row').attr('data-pension-row-id'); // Get the row id
     var transactionType = $('#pension_transaction_type_'+row_id).val(); // Retrieve the transaction type value
     var name = $('#pensionCommutationNumber_'+row_id).val(); // Retrieve the Pension Commutation Value
}