我有一个表格,需要隐藏送货地址,当您取消选中复选框(与账单地址相同的送货地址)时,送货地址字段变得可见。此外,除非未选中复选框,否则帐单地址需要填写与送货地址相同。
简而言之,将帐单地址复制到 shippingaddress 和 shippingaddress 不可见,当未选中时,shippingaddress 变得可见并且字段为空。
我从这里开始;希望有人可以帮助我!
http://jsfiddle.net/fourroses666/P7RhF/3/
<form>
<p class="form-row form-row-first">
<label>Firstname <abbr class="required" title="verplicht">*</abbr></label><br />
<input type="text" placeholder="Firstname" name="firstname:required" id="firstname" />
</p>
<h2>Deliver address</h2>
<p id="shiptobilling" class="form-row">
Same as Shipping <input type="checkbox" onclick="SetBilling(this.checked);" />
</p>
<div class="shipping_address" style="display:none;">
<p class="form-row form-row-first">
<label>Voornaam <abbr class="required" title="verplicht"></abbr></label><br />
<input type="text" placeholder="Firstname" name="deliver_firstname" id="deliver_firstname" />
</p>
</div>
<input class="btn" type="submit" value="Checkout" name="checkout" />
</form>
和脚本:
<script type="text/javascript" language="javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
function SetBilling(checked) {
if (checked) {
document.getElementById('firstname').value = document.getElementById('deliver_firstname').value;
} else {
document.getElementById('firstname').value = '';
}
}
</script>