2013-06-24 3 views
0

MVC 프로젝트에서 고객이 계정을 만들면 인보이스 주소와 배송지 주소를 묻습니다.은 자동으로 필드를 업데이트합니다.

동일한 주소를 두 번 입력하지 않아도 동일한 인보이스 주소 세부 정보로 배송 주소를 업데이트하는 인보이스 주소 아래의 확인란이 필요합니다. 체크 박스의 예

<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은 동일한 세부 정보를 두 번 입력해야합니다.

<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를 사용하여 배송 주소를 인보이스와 동일한 주소로 자동 업데이트하고 싶습니다. 당신은 당신의 열을 식별하기 위해 뭔가를해야합니다

답변

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()) ; 
}); 
+0

괜찮습니다. 도움에 감사드립니다. Erik – John

관련 문제