用于将帐单文本框复制到发货文本框的复选框的Javascript

用于将帐单文本框复制到发货文本框的复选框的Javascript,javascript,forms,textbox,Javascript,Forms,Textbox,到目前为止,我一直在试图找到一种好方法,当用户选中复选框表示其账单信息与发货信息相同时,在文本框中获取账单信息,并将信息复制到发货信息文本框中 到目前为止,我有以下代码: function InputInformation(n) { if(n.checked === false) { return; } document.subscribe.billingfname.value = document.subscribe.shippingfname.v

到目前为止,我一直在试图找到一种好方法,当用户选中复选框表示其账单信息与发货信息相同时,在文本框中获取账单信息,并将信息复制到发货信息文本框中

到目前为止,我有以下代码:

    function InputInformation(n) {   
        if(n.checked === false) { return; }
        document.subscribe.billingfname.value = document.subscribe.shippingfname.value;
        document.subscribe.billinglname.value = document.subscribe.shippinglname.value;
        document.subscribe.billingaddress.value = document.subscribe.shippingaddress.value;
        document.subscribe.billingcity.value = document.subscribe.shippingcity.value;
        document.subscribe.billingstate.value = document.subscribe.shippingstate.value;
        document.subscribe.billingzip.value = document.subscribe.shippingzip.value;
        document.subscribe.billingphone.value = document.subscribe.shippingphone.value;
        }
          return InputInformation;
我无法让它工作。我不确定我做错了什么。任何帮助都会很好

javascript采用以下形式:

<form class="wrap" name="subscribe">
            <tr class="left-container">
            <h2>Billing Information:</h2>
            <td>
                <span class="labels">First name: </span>
            <input type="text" name="billingfname">
            </td>
                <br>
                <td>
            <span class="labels"> Last name: </span>
            <input type="text" name="billinglname">
            </td>
                <br>
                <td>
            <span class="labels">Address: </span>
            <input type="text" name="billingaddress" style="width: 200px">
           </td>
                <br>
                <td>
            <span class="labels">City: </span>
            <input type="text" name="billingcity">
            </td>
                <br>
                <td>
            <span class="labels">State: </span>
            <input type="text" name="billingstate">
            </td>
                <br>
                <td>
            <span class="labels">Zip Code: </span>
            <input type="text" name="billingzip" style="width: 80px">
            </td>
                <br>
                <td>
            <span class="labels">Telephone </span>
            <input type="text" name="billingphone" style="width: 80px">
                    </td>
            </tr>
            <tr class="right-container">
            <h2>Shipping Information:</h2>
                <td>
                <input class="shipping" type="checkbox" onclick="InputInformation(this)">Check if Shipping is the same as Billing
                </td>
                <br>
                <td>
            <span class="labels">First name: </span>
            <input type="text" name="shippingfname">
            </td>
                <br>
                <td>
            <span class="labels"> Last name: </span>
            <input type="text" name="shippinglname">
            </td>
                <br>
                <td>
            <span class="labels">Address: </span>
            <input type="text" name="shippingaddress" style="width: 200px">
             </td>
                <br>
                <td>
            <span class="labels">City: </span>
            <input type="text" name="shippingcity">
            </td>
                <br>
                <td>
            <span class="labels">State: </span>
            <input type="text" name="shippingstate">
           </td>
                <br>
                <td>
            <span class="labels">Zip Code: </span>
            <input type="text" name="shippingzip" style="width: 80px">
            </td>
                <br>
                <td>
            <span class="labels">Telephone </span>
            <input type="text" name="shippingphone" style="width: 80px">
                    </td>
            </tr>
</form>

账单信息:
名字:

姓氏:
地址:
城市:
声明:
邮政编码:
电话 装运信息: 检查发货是否与账单相同
名字:
姓氏:
地址:
城市:
声明:
邮政编码:
电话
我猜您是在试图将发货复制到您的代码片段中的账单,而不是这样

检查下面的代码片段

函数输入信息(n){
如果(n.checked==false){alert('sdf');返回false;}
document.subscribe.shippingfname.value=document.subscribe.billingfname.value;
document.subscribe.shippinglname.value=document.subscribe.billinglname.value;
document.subscribe.shippingaddress.value=document.subscribe.billingaddress.value;
document.subscribe.shippingcity.value=document.subscribe.billingcity.value;
document.subscribe.shippingstate.value=document.subscribe.billingstate.value;
document.subscribe.shippingzip.value=document.subscribe.billingzip.value;
document.subscribe.shippingphone.value=document.subscribe.billingphone.value;
}

账单信息:
名字:

姓氏:
地址:
城市:
声明:
邮政编码:
电话 装运信息: 检查发货是否与账单相同
名字:
姓氏:
地址:
城市:
声明:
邮政编码:
电话
返回的输入信息是什么;这是从哪里来的?您似乎在函数定义之外有
return
语句。那是故意的还是错误的?对不起,是的,那是个错误,但它仍然不起作用。非常感谢你,我不知道我把它们换了。但由于某些原因,在修复代码后,它仍然无法在我的代码中工作。当我在这里运行您的代码时,它会工作,但在我的文本编辑器中不会。有什么建议吗?