如何通过点击事件禁用智能街道/实时地址
How to disable SmartyStreets/LiveAddress via onclick event
我继承了在SquirrelCart购物车应用程序中实现的SmartyStreets/LiveAddress代码,并且需要帮助找出语法以禁用SmartyStreets/LiveAddress验证,该事件将帐单地址字段复制到送货地址字段中。
特别是对于国际地址(即美国境外(,在他们已经验证了账单地址之后,必须通过送货地址的验证过程真的很烦人。
我目前已将地址初始化为:
/* SmartyStreets */
jQuery.LiveAddress(
{
key: "18924899",
invalidMessage: "Not a valid US Postal address.</br>Please correct or certify below.",
debug: "true",
addresses: [
// Squirrelcart billing address
{
id: 'Billing',
street: '#Bill_Street',
city: '#Bill_City',
state: '#Bill_State_or_Province',
zipcode: '#Bill_Postal_Code',
country: '#Bill_Country'
},
// Squirrelcart shipping address
{
id: 'Shipping',
street: '#Ship_Street',
city: '#Ship_City',
state: '#Ship_State_or_Province',
zipcode: '#Ship_Postal_Code',
country: '#Ship_Country'
},
// Squirrelcart account address
{
id: 'Account',
street: '#Street',
city: '#City',
state: '#State_or_Province',
zipcode: '#Postal_Code',
country: '#Country'
}
],
autoVerify: false,
deactivate: 'Shipping'
}
);
与将帐单邮寄地址复制到送货地址相关联的 HTML 代码为:
<p>If your shipping address is the same as your billing address, clicking the
"Same as Billing button will copy it into the fields below for you.
If your shipping address is different, please type it in the fields below.</p>
<div align="center"><a class="btn btn_same_as_billing" href="#">Same as Billing</a></div>
相关的 SquirrelCart JavaScript 函数:
/*************************************************************
Setup various aspects of the store
*************************************************************/
function scStoreSetup() {
< ... snip ... >
$$('.btn_same_as_billing').addEvent('click',function(evt) {scAddressCopy(evt);});
< ... snip ... >
}
/*************************************************************
Function copies fields from billing to shipping address
*************************************************************/
function scAddressCopy(evt) {
// prevents the page from jumping position
evt.stop();
var form = document.address_form;
var billFldId, shipFldId, billFld, shipFld;
// loop thru fields
for(x=0; x < form.elements.length; x++) {
billFldId = form.elements[x].id;
billFld = form.elements[x];
// if we are on a bill field
if (billFldId.indexOf('Bill_') != -1) {
// change id to matching ship field
shipFldId = billFldId.replace('Bill_','Ship_');
// grab ship field and set it
shipFld = document.getElementById(shipFldId);
if (shipFld) shipFld.value = billFld.value;
}
}
}
/*************************************************************
Handle things specific to address form
*************************************************************/
function addrForm(elem, evt) {
if (elem.id == 'Bill_State_Other' && evt.type == 'keyup') {
if (elem.value.length) {
// set state or province field to 'Other'
if (document.getElementById('Bill_State_or_Province')) document.getElementById('Bill_State_or_Province').value = 2
}
} else if (elem.id == 'Ship_State_Other' && evt.type == 'keyup') {
if (elem.value.length) {
// set state or province field to 'Other'
if (document.getElementById('Ship_State_or_Province')) document.getElementById('Ship_State_or_Province').value = 2
}
} else if (elem.id == 'Bill_State_or_Province' && evt.type == 'change') {
if (document.getElementById('Bill_State_Other')) {
var stateOther = document.getElementById('Bill_State_Other');
if (elem.options[elem.selectedIndex].value == '2') {
stateOther.value = '';
stateOther.focus();
} else {
stateOther.value='';
}
}
} else if (elem.id == 'Ship_State_or_Province' && evt.type == 'change') {
if (document.getElementById('Ship_State_Other')) {
var stateOther = document.getElementById('Ship_State_Other');
if (elem.options[elem.selectedIndex].value == '2') {
stateOther.value = '';
stateOther.focus();
} else {
stateOther.value='';
}
}
}
}
似乎我应该能够通过使用onclick事件来禁用或停用LiveAddress(尤其是对于国际地址(,例如,
<a class="btn btn_same_as_billing" href="#" onclick="$('form#address_form').deactivate('Shipping');">Same as Billing</a>
其中"address_form"是表单的 ID:
<form id="address_form" class="sc_form" accept-charset="utf-8" name="address_form" action="<?php print $Form_Action?>" method="post">
我在拨入语法时遇到了真正的困难。帮我?
最好玛蒂
<input type="button" name="Copy" value="Copy Billing Address" id="billingtoshipping_checkbox">
<script type="text/javascript">
$(document).ready(function(){
$("#billingtoshipping_checkbox").click(function(){
$("[id^='shipping_']").each(function(){
data=$(this).attr("id")
tmpID = data.split('shipping_');
$(this).val($("#billing_"+tmpID[1]).val())
})
});
});
</script>
相关文章:
- 三星智能电视应用程序;Brightcove示例应用程序远程控制问题
- 更改智能表中的页面将停止JQuery函数的工作
- AngularJS智能表全局配置实现
- 创造自己的智能
- 如何在智能表中按日期对项目进行排序
- 如何为AngularJS制作智能表中第一页和最后一页的跳过按钮
- 三星智能电视应用程序使用谷歌API
- 正在检测智能手机浏览器上的悬停或鼠标悬停
- JetBrains网络风暴智能感知
- HTML文件中的智能Javascript建议在Visual Studio代码更新后没有日志程序工作
- 智能窗体只弹出日期选择器而不是时间选择器
- 用背景色智能填充引导列
- 导航到fiori智能模板
- plupload智能手机和平板电脑浏览按钮事件未启动
- 三星智能电视唯一的设备标识符
- Redux-组件不同的方法(智能/哑点/容器/演示)
- 适用于可在网络浏览器和智能手机上运行的网站的 MP3 播放器
- 在手持/智能设备上使用不同浏览器时的屏幕宽度问题
- 停用智能街道功能
- 如何通过点击事件禁用智能街道/实时地址