如何将送货地址复制到帐单地址
我想知道是否可以将送货地址复制到帐单地址。当用户单击与送货地址相同的复选框时。送货地址值将被复制到账单输入字段。我完成了大部分部分,但我不确定如何将选择菜单(状态)值复制到帐单地址。我真的很感谢任何帮助。
我的代码
$(document).ready(function(){
Jquery
$('#same').click(function(){
if($('#same').attr('checked')){
$('#bfName').val($('#fName').val());
$('#blName').val($('#lName').val());
$('#baddress1').val($('#address1').val());
$('#baddress2').val($('#address2').val());
$('#bcity').val($('#city').val());
alert(($('#state option:selected').val())); //not sure what to do here
$('#bzip').val($('#zip').val());
};
});
Html
<td><select name="state"> //shipping states......only partial codes.
<option value="">None
<option value="AL">Alabama
<option value="AK">Alaska
<option value="AZ">Arizona
<option value="AR">Arkansas
<option value="CA">California
<option value="CO">Colorado
<option value="CT">Connecticut
</select></td>
<td><select name="bstate"> //billing state................only partial codes.
<option value="">None
<option value="AL">Alabama
<option value="AK">Alaska
<option value="AZ">Arizona
<option value="AR">Arkansas
<option value="CA">California
<option value="CO">Colorado
<option value="CT">Connecticut
</select></td>
非常感谢!
I like to know if I can copy the shipping address to billing address. When a user clicks same as shipping address checkbox. The shipping address value will be copied to billing input field. I got most of the parts done but I am not sure how to copy select menu (states) value to billing address. I really appreciate any helps.
My code
$(document).ready(function(){
Jquery
$('#same').click(function(){
if($('#same').attr('checked')){
$('#bfName').val($('#fName').val());
$('#blName').val($('#lName').val());
$('#baddress1').val($('#address1').val());
$('#baddress2').val($('#address2').val());
$('#bcity').val($('#city').val());
alert(($('#state option:selected').val())); //not sure what to do here
$('#bzip').val($('#zip').val());
};
});
Html
<td><select name="state"> //shipping states......only partial codes.
<option value="">None
<option value="AL">Alabama
<option value="AK">Alaska
<option value="AZ">Arizona
<option value="AR">Arkansas
<option value="CA">California
<option value="CO">Colorado
<option value="CT">Connecticut
</select></td>
<td><select name="bstate"> //billing state................only partial codes.
<option value="">None
<option value="AL">Alabama
<option value="AK">Alaska
<option value="AZ">Arizona
<option value="AR">Arkansas
<option value="CA">California
<option value="CO">Colorado
<option value="CT">Connecticut
</select></td>
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试一下。
Give this a try.
这有用吗?
您可能需要将 id 属性添加到账单和运输状态中,选择“astate”和“bstate”,因为我似乎找不到:)
does this work ?
you may need to add id attribute to that billing and shipping state select as 'astate' and 'bstate', as i can't seems to find one :)
在 html 页面上,州和国家/地区是下拉列表,复选框是:
on the html page the state and country are dropdowns and the checkbox is: