所以我知道字段已正确命名,但是当复选框被选中时,javascript仍未复制信息。我已经仔细检查了,所有内容都匹配在字段中。
JavaScript的:
function FillShiping(f) {
if(f.shipingtoo.checked == true) {
f.shipto.value = f.billto.value;
f.shipaddress.value = f.Address.value;
f.shipcity.value = f.City.value;
f.shipstate.value = f.State.value;
f.shipzip.value = f.Zip.value;
}
if(f.shipingtoo.checked == false) {
f.shipto.value = '';
f.shipaddress.value = '';
f.shipcity.value = '';
f.shipstate.value = '';
f.shipzip.value = '';
}
}
HTML:
<div class="fb-checkbox">
<input type="checkbox" onclick="Fillshiping(this.form)" name="shipingtoo">
<span class="fb-fieldlabel" id="item61_0_span">Check this if shipping address is same
as billing address </span>
</label>
</div>
</div>
答案 0 :(得分:4)
控制台显示错误:
ReferenceError:未定义Fillshiping
您将该函数命名为FillShiping
,但您正在调用Fillshiping(this.form)
(小写s
)。
correcting your fiddle 和 naming the function properly, it seems to work之后。
使用浏览器的开发人员工具调试代码,这是非常宝贵的。