简体   繁体   中英

Value of radio button copy to text field

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>

$_GET just checks the query string in the URL (the part of the URL after the /? ) for variables. Look at the URL the form actually submits to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM