单选按钮的值复制到文本字段 [英] Value of radio button copy to text field

查看:192
本文介绍了单选按钮的值复制到文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我终于弄清楚如何应用j-query来计算联系人表单7的单选按钮格式。我遇到的问题是我必须将格式(迷你会话$ 100.00)转换为(100.00 Mini会话)以使其计算。我很想拥有它(迷你会议$ 100.00)。我也希望将选择的单选按钮的值复制到文本字段。



这是我的形式,它已经建立在联系表格7 formmat。

 < p>您的姓名(必填)< br /> 
名字:[text * RYSFN 20/20 id:RYSFN]姓氏:[text * RYSLN 20/20 id:RYSLN]< / p>

< p>您的电子邮件(必填)< br />
[email * RYSEM id:RYSEM]< / p>

< p>您的电话号码(必填)< br />
[text * RYSPN 15/15 id:RYSPN placeholder(###) - ### - ####]< / p>

< p>地址(必需)< br />
街道地址[text * RYSaddress0 55/50]
地址行2 [文本* RYSaddress1 55/50]
城市[文本* RYSaddress2 20/20]状态[文本* RYSaddress3 4/4 ]邮政编码[text * RYSaddress4 7/7]< / p>

< p>会话日期< br />
会话日期:[文本* RYSSD 20/20 id:RYSSD1占位符月DD YYYY]< / p>

< p>会话类型< br />
[radio RYSYFS id:RYSYFS class:radio-vertical class:wpcf7-list-item-labelMaternityFamilyNewbornBaby / Toddler / ChildCake SmashMilestone / p为H.

< p>会话支付类型< br />
[radio RYSSPT id:RYSSPT class:radio-vertical class:wpcf7-list-item-label100.00 Mini SessionFull Session $ 250.00]< / p>

< p> Extra People< br />
[radio RYSEP id:RYSEP class:radio-vertical class:wpcf7-list-item-label25.00 1个人2人50.003人75.004人$ 100.00]

< p>会话产品:< br />
会话类型:[text RYSTS 23/23 id:RYSTS1]
会话付款:[文本RYSSP 8/8 id:RYSSP]
额外的人:[文本RYSEP 8/8 id: RYSEP] LT; / p为H.

< p>会话支付金额:< br />
总金额:[文本RYSTotal 8/8 id:RYSTotal]
存款金额:[文本RYSDA 8/8 ID:RYSDA]
余额金额:[文本RYSBA 8/8 ID:RYSBA ]
余额到期日:[text RYSBDB 20/20 id:RYSBDB]

< p>我承认这是一个不可退还的可转让费用,用于保留会议约会。我承担这个保留是不退还的。 < br />
[checkbox * RYSAgreeRYSAgree]< / p>

付款细目:
总金额:< span id =total>< / span>
存款金额:< span id =deposit>< / span>
余额金额:< span id =balance>< / span>
余额到期日:[text RYSBA2 20/20 id:RYSBA2]

< p>您如何通过以下方式支付剩余余额(会前到期) br />
[radio RYSPB id:RYSPB class:radio-verticalA PayPal Invoice Apx。在会议之前2周。 PayPal发票在会议前一天。 我将使用借记卡或信用卡在会议日期支付余额。]

< p> [提交发送]< / p>

我的java脚本来计算和复制字段

 < script type =text / javascript> 
$(document).ready(function(){
$(#RYSSD1)。keyup(function(){
$('#RYSBDB')。val )
$('#RYSBA2')val($(this).val());
});
var inputs = $('input [ name =RYSSPT],输入[name =RYSEP]');
$(inputs).click(function(){
var total = 0;
$ .filter(':checked')。each(function(){
total = total + parseInt($(this).val());
})
$('#total ').html('$'+ total);
$('#deposit')。html('$'+(total / 2));
$('#balance' ('$'+(total / 2));
});
});
< / script>

我的下一个问题是如何将单选按钮值复制到文本字段如何将其添加到剧本。我有另一个问题,当我得到总计0在最终剂量不显示。






仍然在表单上工作



单选按钮值复制到指定的文本字段

  $('#1')。blur(function(){
$('#3')。val($(this).val());
});

如何将单选按钮的值赋予命名文本字段。

解决方案

替换整个< script> ..< / script> bit with this ...

 < script> 
$(document).ready(function(){
$(#RYSSD1)。keyup(function(){
$('#RYSBDB')。val )
$('#RYSBA2')val($(this).val());
});
var inputs = $('input [ name =RYSSPT],输入[name =RYSEP]');
$(inputs).click(function(){
var total = 0;
$每个(function(){
var value =($(this).val())。match(/ \ $([0-9] *)/)[ 1];
total = total + parseInt(value);
})
$('#total')。html('$'+ total);
$(' #$ html('$'+(total / 2));
$(' val('$'+(total / 2));
$('#RYSBA')。 .val('$'+(total / 2));
});
$('input [name =RYSYFS ]')。click(function(){
$(this).blur();
$('#RYSTS1')。val($(this).val());
$)
$('input [name =RYSSPT')。click(function(){
$(this).blur();
$(' RYSSP')val($(this).val());
})
$('input [name =RYSEP')click(function(){
$ (this).blur();
$('#RYSEP')。val($(this).val());
})
});
< / script>


I finally figured out how to apply j-query to calculate contact form 7's radio button format. The problem I am having is I have to reverses the format ( mini session $100.00) to ( 100.00 Mini session) to get it to calculate. I would love to have it ( mini session $100.00). I also would love to copy the value of the radio button that has been selected to copy to a text field.

Here is my form it been built in Contact form 7 formmat.

    <p>Your Name (required)<br />
    First Name: [text* RYSFN 20/20 id:RYSFN]   Last Name: [text* RYSLN 20/20 id:RYSLN]</p>

<p>Your Email (required)<br />
    [email* RYSEM id:RYSEM] </p>

<p>Your Phone Number (required)<br />
    [text* RYSPN 15/15 id:RYSPN placeholder "(###) - ### - ####"]</p>

<p>Address (required)<br />
  Street Address [text* RYSaddress0 55/50] 
  Address Line 2 [text* RYSaddress1 55/50] 
  City [text* RYSaddress2 20/20]  State [text* RYSaddress3 4/4] Zip code [text* RYSaddress4 7/7] </p>

<p>Session Date<br />
    Session date: [text* RYSSD 20/20 id:RYSSD1 placeholder "Month DD YYYY"]</p>

<p>Session Type<br />
[radio RYSYFS id:RYSYFS class:radio-vertical class:wpcf7-list-item-label "Maternity" "Family" "Newborn" "Baby / Toddler / Child" "Cake Smash" "Milestone"]</p>

<p>Session payment Type<br />
[radio RYSSPT id:RYSSPT class:radio-vertical class:wpcf7-list-item-label "100.00 Mini Session" "Full Session $250.00"]</p>

<p>Extra People<br />
[radio RYSEP id:RYSEP class:radio-vertical class:wpcf7-list-item-label "25.00 1 Person" "2 People 50.00 " "3 People 75.00 " "4 People $100.00 "]

<p>Session Products: <br />
Type of session: [text RYSTS 23/23 id:RYSTS1]
Session Payment: [text RYSSP 8/8 id:RYSSP]
Extra people: [text RYSEP 8/8 id:RYSEP]</p>

<p>Session Payment Amount: <br />
Total Amount: [text RYSTotal 8/8 id:RYSTotal]
Deposit Amount: [text RYSDA 8/8 id:RYSDA]
Balance Amount: [text RYSBA 8/8 id:RYSBA]
Balance Due By: [text RYSBDB 20/20 id:RYSBDB]

<p>I under stand this is a non- refundable, transferrable fee required to reserve an session appointment.  I under stand this retainer is non-refundable. <br />
[checkbox* RYSAgree "RYSAgree"] </p>

Breakdown Of Payment:
Total Amount: <span id="total"></span>
Deposit Amount: <span id="deposit"></span>
Balance Amount: <span id="balance"></span> 
Balance Due By: [text RYSBA2 20/20 id:RYSBA2]

<p>How would you like to pay the remaining balance (due prior to the session) via:<br />
[radio RYSPB id:RYSPB class:radio-vertical "A PayPal Invoice Apx. 2 weeks before the session." "A PayPal Invoice Apx. day before the session." "I will pay the balance the day of the session With a debit or credit card."]

<p>[submit "Send"]</p>

My java Script to calculate and copy field

<script type="text/javascript">
    $(document).ready(function() {
        $("#RYSSD1").keyup(function() {
            $('#RYSBDB').val($(this).val());
            $('#RYSBA2').val($(this).val());
       });
        var inputs = $('input[name="RYSSPT"], input[name="RYSEP"]');
        $(inputs).click(function() {
            var total = 0;
            $(inputs).filter(':checked').each(function() {
                total = total + parseInt($(this).val());
            })
            $('#total').html('$' + total);
            $('#deposit').html('$' + (total / 2));
            $('#balance').html('$' + (total / 2));
});
    });
</script>

My next question is How do I Copy radio button value to a text field And how to add it to the script. I have another problem as when I get the total the 0 at the end dose not show.


Still working on form

will this work to get radio button value to copy to a named text field

  $('#1').blur(function() {
  $('#3').val($(this).val());
});

How do I get the vale of a radio button to a named text field.

解决方案

Replace your whole <script>..</script> bit with this...

<script>
    $(document).ready(function() {
        $("#RYSSD1").keyup(function() {
            $('#RYSBDB').val($(this).val());
            $('#RYSBA2').val($(this).val());
        });
        var inputs = $('input[name="RYSSPT"], input[name="RYSEP"]');
        $(inputs).click(function() {
            var total = 0;
            $(inputs).filter(':checked').each(function() {
                var value = ($(this).val()).match(/\$([0-9]*)/)[1];
                total = total + parseInt(value);
            })
            $('#total').html('$' + total);
            $('#deposit').html('$' + (total / 2));
            $('#balance').html('$' + (total / 2));
            $('#RYSTotal').val('$' + total);
            $('#RYSDA').val('$' + (total / 2));
            $('#RYSBA').val('$' + (total / 2));
        });
        $('input[name="RYSYFS"]').click(function() {
            $(this).blur();
            $('#RYSTS1').val($(this).val());
        })
        $('input[name="RYSSPT"').click(function() {
            $(this).blur();
            $('#RYSSP').val($(this).val());
        })
        $('input[name="RYSEP"').click(function() {
            $(this).blur();
            $('#RYSEP').val($(this).val());
        })
    });
</script>

这篇关于单选按钮的值复制到文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆