2011-11-19 31 views
2

我試圖通過單擊將送貨地址複製到帳單地址。 正如你在這裏可以看到它適用於我從一個網站上找到的示例:http://jsfiddle.net/aDNH7/複製帳單和送貨地址字段複製到另一個

我的問題是當我將代碼實現到表單中時,它不起作用。我在某處做錯了事,但我不確定。

我的代碼在這裏。如果你能幫助我找到問題,我會解決這個問題。

<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> 

回答

2

您在billng_first_name有一個錯字。你錯過了i

billng_替換爲billing_

+0

非常感謝。這些都是小事,但是當你沒有看到它會讓人發瘋。再次感謝。 – SNaRe

+0

是的SNaRe我知道你的意思,也rember'滴答'的答案接受 – david

+0

對不起。我是一個新的計算器用戶。我不知道爲什麼我以前不在這裏使用。 – SNaRe

相關問題