我想知道我是否可以将送货地址复制到帐单地址.当用户点击与送货地址相同时复选框.送货地址值将复制到开票输入字段.我完成了大部分部分,但我不确定如何将选择菜单(状态)值复制到
我的代码
$(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>
非常感谢!
试一试.var state = $('#state option:selected').val(); $('#bstate option[value=' + state + ']').attr('selected','selected');