0

私の MVC プロジェクトでは、顧客がアカウントを作成すると、請求先住所と配送先住所の入力が求められます。

同じ住所を 2 回入力するのではなく、同じ請求先住所の詳細で配送先住所を更新する、請求先住所の下のチェック ボックスが必要です。

方法がわからないので、助けていただければ幸いです)チェックボックスの例は次のとおりです

<div class="checkbox">@Html.CheckBoxFor(m => signup.SameAddress)</div>
<div class="label">@Html.LabelFor(m => signup.SameAddress, T(Use same address as billing"))</div>

これまでのところ、私のコードは次のようになっています(以下)。ATM では、同じ詳細を 2 回入力する必要があります。

<article class="addresses form">
<fieldset>
    <div class="span5">
    <h2>@T("Invoice Address")</h2>

    <table class="table-bordered table-striped table">
        <colgroup>
            <col id="Col1" />
            <col id="Col2" />
        </colgroup>
        <thead>
            <tr>
                <th scope="col">@T("Name")</th>
                <td>@invoiceAddress.Name.Value</td>
            </tr>
            <tr>
                <th scope="col">@T("AddressLine1")</th>
                <td>@invoiceAddress.AddressLine1.Value<</td>
            </tr>              
        </thead>
    </table>
    </div>

    //insert checkbox here

    <div class="span5">
    <h2>@T("Billing Address")</h2>
    <table class="table-bordered table-striped table">
        <colgroup>
            <col id="Col1" />
            <col id="Col2" />
        </colgroup>
        <thead>
            <tr>
                <th scope="col">@T("Name")</th>
                <td>@shippingAddress.Name.Value</td>
            </tr>
            <tr>
                <th scope="col">@T("AddressLine1")</th>
                <td>@shippingAddress.AddressLine1.Value<</td>
            </tr>               
        </thead>

    </table>
    </div>
</fieldset>
</article>

JQuery または JS を使用して、配送先住所を請求書に指定された住所と同じ住所に自動的に更新したいと考えています。

返信ありがとうございます...

4

1 に答える 1

1

列を識別するために何かが必要になります。ここでは、選択できる ID を持つ入力タグを使用しました。

<input type="checkbox" id="test3"/>
<label for="test1">Invoice address</label><input id="test1" type="text"/>
<label for="test2">Shipping address</label><input id="test2" type="text"/>


$("#test1").on("change", function () {
    if ($("#test3").is(":checked"))
        $("#test2").val($(this).val()) ;
});
于 2013-06-24T13:12:42.440 に答える