2段JS代码冲突,提示elements为空或不是对象,看看怎么回事?
<script type="text/javascript">function $id(element) {
return document.getElementById(element);
}
//切屏--是按钮,_v是内容平台,_h是内容库
function reg(str){
var bt=$id(str+"_b").getElementsByTagName("h2");
for(var i=0;i<bt.length;i++){
bt[i].subj=str;
bt[i].pai=i;
bt[i].style.cursor="pointer";
bt[i].onclick=function(){
$id(this.subj+"_v").innerHTML=$id(this.subj+"_h").getElementsByTagName("blockquote")[this.pai].innerHTML;
for(var j=0;j<$id(this.subj+"_b").getElementsByTagName("h2").length;j++){
var _bt=$id(this.subj+"_b").getElementsByTagName("h2")[j];
var ison=j==this.pai;
_bt.className=(ison?"":"h2bg");
}
}
}
$id(str+"_h").className="none";
$id(str+"_v").innerHTML=$id(str+"_h").getElementsByTagName("blockquote")[0].innerHTML;
}
</script>
和下面这一段冲突
<script type="text/javascript">
/* *
* 快速通道
*/
function orderQuick(goodsId)
{
var goods = new Object();
var spec_arr = new Array();
var fittings_arr = new Array();
var number = 1;
var formOrder = document.forms['ECS_FORMORDER'];
if (formOrder)
{
goods.spec_arr = getSelectedAttributes(formOrder);
goods.goods_id = goodsId;
goods.number = formOrder.elements['number'].value;
goods.country = formOrder.elements['country'].value;
goods.province = formOrder.elements['province'].value;
goods.city = formOrder.elements['city'].value;
goods.consignee = formOrder.elements['consignee'].value;
goods.email = formOrder.elements['email'].value;
goods.address = formOrder.elements['address'].value;
goods.tel = formOrder.elements['tel'].value;
if (formOrder.elements['zipcode']){goods.zipcode = formOrder.elements['zipcode'].value;}
if (formOrder.elements['mobile']){goods.mobile = formOrder.elements['mobile'].value;}
if (formOrder.elements['sign_building']){goods.sign_building = formOrder.elements['sign_building'].value;}
if (formOrder.elements['best_time']){goods.best_time = formOrder.elements['best_time'].value;}
if (formOrder.elements['postscript']){goods.postscript = formOrder.elements['postscript'].value;}
}
Ajax.call('order_quick.php?act=order', 'goods=' + goods.toJSONString(), orderQuickResponse, 'POST', 'JSON');
}
</script>
[ 本帖最后由 wangyizxl 于 2010-4-12 12:34 编辑 ]