2013-09-22 99 views
0

我正在使用CMS的事件,这个CMS不支持多种付款选择,所以我设法做了一些修改的核心,我已经添加了一些新的类,控制器,助手,和模型,所以我可以添加多个支付选择,我这样做是因为上次我问如何对CMS进行修改时,您告诉我不是更改核心,而是根据需要添加新的类或控制器,以便安全风险将是最小的,所以这就是我所做的...更改attr根据选择输入

反正多支付系统的“工作”有小小的瑕疵... 用户必须选择2点主要的选择

1是选择该每月的百分比 另一种是用于选择付款方式,如PayPal,eWay,Google Checkout,Payza等...

因此,每笔付款都有不同的费率类型的说话......但在这种情况下,他们每月支付率和付款方式都有相同的速度...

所以我想知道,而不是点击两个类似的选项,为什么不只是点击一个选项,并将值传递给另一个选项没有需要再次点击...

我已简化了HTML代码以便更好地理解

<div class="hides"> 
    <p class="title">This area is not visible in a live site<p><br> 
<input type="radio" checked="checked" name="eb_PagosMensuales" value="Un Solo Pago (0%)" class="inputbox flush">Un Solo Pago (0%) 
<br> 
<input type="radio" name="eb_PagosMensuales" value="3 Meses (+4.55%)" class="inputbox flush">3 Meses (+4.55%) 
<br> 
<input type="radio" name="eb_PagosMensuales" value="6 Meses (+7.25%)" class="inputbox flush">6 Meses (+7.25%) 
<br> 
<input type="radio" name="eb_PagosMensuales" value="9 Meses (+11.25%)" class="inputbox flush">9 Meses (+11.25%) 
<br> 
<input type="radio" name="eb_PagosMensuales" value="12 Meses (+13.50%)" class="inputbox flush">12 Meses (+13.50%) 
<br> 
</div> 

<hr /> 

<div> 
<input type="radio" checked="checked" value="os_paypal" name="payment_method" onclick="changePaymentMethod();">Paypal 0% Intereses <br> 
<input type="radio" value="os_paypal3" name="payment_method" onclick="changePaymentMethod();">Paypal a 3 Meses con 4.55% de Interes <br> 
<input type="radio" value="os_paypal4" name="payment_method" onclick="changePaymentMethod();">PayPal a 6 Meses con 7.25% de Interes <br> 
<input type="radio" value="os_paypal5" name="payment_method" onclick="changePaymentMethod();">Paypal a 9 Meses con 11.25% de Interes <br> 
<input type="radio" value="os_paypal6" name="payment_method" onclick="changePaymentMethod();">Paypal a 12 Meses con 13.50% de Interes <br> 
</div> 

如果用户选择

贝3,然后用值的输入单选按钮 “3个月前(+ 4.55%)” 将被选择自动

如果用户选择

贝6,然后用值的输入单选按钮“6个月前(+ 7.25%),”将selectec自动

等等...

这就是我想要查询使用...我知道这是不完成,我想,如果这几行工作,那么其余的将是简单的,但不工作,我得到秃头拉我的头发...

$('input[name*=payment_method]').live('change', function() { 

if ($('input[name*=os_paypal]').is(':checked')) { 
     $('input[name*=eb_PagosMensuales')[0].setAttribute('checked', 'checked'); 
    alert("PayPal 1 has been selected..."); 
} 

/* else { 
    $('#some_other_id_that_i_migh_need').removeAttr('required'); 
    } 
    */ 
}); 

这个想法是从第二组单选按钮中选择1个选项,并且通过这样做第一组单选按钮中的一个将相应地选择到第二组上的数据。

请看看这里更直观例子: Link to jsfiddle

感谢您百忙之中阅读我的问题的时候,我感谢所有帮助您可以提供。

回答

0

尝试

var $ebs = $('input[name="eb_PagosMensuales"]'); 
var $paymethods = $('input[name=payment_method]').on('change', function() { 
    var idx = $paymethods.index(this); 
    $ebs.eq(idx).prop('checked', true) 
}); 

演示:Fiddle