0

我正在使用 CMS 进行活动,这个 CMS 不支持多种支付选择,所以我设法对核心进行了一些修改,我添加了一些新的类、控制器、帮助器和模型,以便我可以添加多个付款选择,我这样做是因为上次我问如何对 CMS 进行修改,你们都告诉我应该根据需要添加新的类或控制器,而不是更改核心,这样安全风险就会降到最低,所以这就是我所做的...

无论如何,多重支付系统正在“工作”,但有一个小缺陷......用户必须选择 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>

如果用户选择

PayPal 3,然后将自动选择值为“3 Meses (+4.55%)”的输入单选按钮

如果用户选择

PayPal 6,然后输入单选按钮值为“6 Meses (+7.25%)”将自动选择

等等...

这是我正在尝试使用的查询...我知道这还没有完成,我在想如果这几行有效,那么其余的将很简单,但不起作用而且我越来越秃了为了拉我的头发...

$('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');
    }
    */
});

这个想法是从第二组单选按钮中选择一个选项,然后根据第二组的数据选择第一组单选按钮中的一个。

请在此处查看更直观的示例: Link to jsfiddle

感谢您花时间阅读我的问题,感谢您提供的任何帮助。

4

1 回答 1

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)
});

演示:小提琴

于 2013-09-22T07:02:59.540 回答