我有一個窗體中有兩個不同的字段集合,一個是帳單地址,另一個是發貨地址。更改表單提交值?
我已經寫了一些jQuery,以便您可以隱藏運輸表單,並用結算表單中的詳細信息(如果您運送到同一地址)填寫它。
這是我的jQuery:
$('#reveal-shipping').click(function(){
if($('.wpsc_checkout_table.table-2').css('display') == 'none'){
$('.wpsc_checkout_table.table-2').slideToggle();
$('.wpsc_checkout_table.table-2').find('input, select, textarea').val('');
document.getElementById('reveal-shipping').innerHTML = 'Ship to my billing address ←';
} else {
//fields is an array containing an array of two selector strings, one for the billing form and one for the shipping.
for (i=0; i < fields.length; i++){
thisval = $(fields[i][0]).val();
$(fields[i][1]).val(thisval);
}
$('.wpsc_checkout_table.table-2').slideToggle();
document.getElementById('reveal-shipping').innerHTML = 'Ship to a different address →';
}
});
我想知道如果我能爲循環運行,這是與價值觀,的onClick提交按鈕,或者隱藏的輸入元素填充部分這些值本來就已經提交了。
如果不是的話,什麼時候該運行這個確保值正確提交的好時機?也許onunfocus? (請告訴我,這實際名稱)提前
上的變化或對賬單輸入KEYUP更新相應的航運輸入 - >無環 – mikakun 2013-04-10 14:01:43
@mikakun聽起來像是一個好主意,但我仍然會使用循環以及當我透露航運我清除他們,如果他們被編輯,然後隱藏和結算不再編輯它將是不準確的 – Bill 2013-04-10 14:08:18