【问题标题】:Copy Billing and Shipping Address Fields Copy to Another复制帐单和送货地址字段复制到另一个
【发布时间】:2017-11-20 20:47:29
【问题描述】:

我正在尝试一键将送货地址复制到帐单地址。 正如您在此处看到的,它适用于我从网站上找到的示例:http://jsfiddle.net/aDNH7/

我的问题是当我在表单中实现代码时,它不起作用。我在某个地方做错了什么,但我不确定。

我的代码在这里。如果你能帮我找到问题,我会appriciate。

<script>

    function FillBilling(f) {

        if(f.billingtoo.checked == true) {

            f.billing_first_name.value = f.first_name.value;

            f.billing_last_name.value = f.last_name.value;

            f.billing_address_1.value = f.address_1.value;

            f.billing_address_2.value = f.address_2.value;

            f.billing_city.value = f.city.value;

            f.billing_state.value = f.state.value;

            f.billing_zipcode.value = f.zipcode.value;



        }

        if(f.billingtoo.checked == false) {

            f.billing_first_name.value = '';

            f.billing_last_name.value = '';

            f.billing_address_1.value = '';

            f.billing_address_2.value = '';

            f.billing_city.value = '';

            f.billing_state.value = '';

            f.billing_zipcode.value = '';

        }

    }

</script>

<form action="http://www......" method="post" accept-charset="utf-8"><h1>SHIPPING ADDRESS</h1>

<label for="first_name">First Name</label>

<div><input type="text" name="first_name" id="first_name" value="" /></div>



<label for="last_name">Last Name</label>

<div><input type="text" name="last_name" id="last_name" value="" /></div>



<label for="address_1">Address 1</label>

<div><input type="text" name="address_1" id="address_1" value=""/></div>



<label for="address_2">Address 2</label>

<div><input type="text" name="address_2" id="address_2" value=""/></div>



<label for="city">City</label>

<div><input type="text" name="city" id="city" disabled="disabled" value="Los Angeles" /></div>



<label for="state">State</label>

<div><input type="text" name="state" id="state" disabled="disabled" value="CA" /></div>



<label for="zipcode">Zip Code</label>

<div><input type="text" name="zipcode" id="zipcode" disabled="disabled" value="90064" /></div>



<label for="phone">Phone</label>

<div><input type="text" name="phone" id="phone" value="" /></div>



<input type="checkbox" onclick="FillBilling(this.form)" name="billingtoo">

<em>Check this box if Billing Address and Mailing Address are the same.</em>



<h1>BILLING ADDRESS</h1>



<label for="billng_first_name">First Name</label>

<div><input type="text" name="billng_first_name" id="billng_first_name" value="" /></div>



<label for="billng_last_name">Last Name</label>

<div><input type="text" name="billng_last_name" id="billng_last_name" value="" /></div>



<label for="billing_address_1">Address 1</label>

<div><input type="text" name="billing_address_1" id="billing_address_1" value=""/></div>



<label for="billing_address_2">Address 2</label>

<div><input type="text" name="billing_address_2" id="billing_address_2" value=""/></div>



<label for="billing_city">City</label>

<div><input type="text" name="billing_city" id="billing_city"  value="" /></div>



<label for="billing_state">State</label>

<div><input type="text" name="billing_state" id="billing_state" value="" /></div>



<label for="billing_zipcode">Zip Code</label>

<div><input type="text" name="billing_zipcode" id="billing_zipcode" value="" /></div>



<div><input type="submit" value="Send" /></div>



</form>

【问题讨论】:

    标签: javascript autocomplete


    【解决方案1】:

    billng_first_name 中有错字。你错过了i

    billng_ 替换为billing_

    【讨论】:

    • 非常感谢。这些都是小事,但当你看不到它时,就会让人发疯。再次感谢。
    • 是的 SNaRe 我知道你的意思,也请记住tick 接受的答案
    • 对不起。我是新的 stackoverflow 用户。我不知道为什么我以前不在这里使用。
    • 是的,它是一个很棒的社区网站,每个人都愿意提供帮助
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多