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

Value of radio button copy to text field

本文关键字:字段 文本 复制 单选按钮      更新时间:2023-09-26

我终于学会了如何应用j-query来计算联系人表单7的单选按钮格式。我遇到的问题是,我必须将格式(小会话100.00美元)反转为(100.00小会话)才能进行计算。我很想拥有它(迷你会话100.00美元)。我也很想复制已选择复制到文本字段的单选按钮的值。

这是我的表格,它是在联系表格7表格中建立的。

    <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>

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

<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>

我的下一个问题是如何将单选按钮值复制到文本字段以及如何将其添加到脚本中。我还有一个问题,当我得到总数时,最后的0没有显示。


仍在处理表单

这能让单选按钮值复制到命名的文本字段吗

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

如何获取命名文本字段的单选按钮值。

将整个<script>..</script>位替换为。。。

<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>

$_GET只是检查URL中的查询字符串(/?之后的URL部分)中的变量。查看表单实际提交到的URL。