首页 新闻 搜索 专区 学院

急!急!急!javascript参数问题,始终找不出原因,望各位路过大仙指点?

0
悬赏园豆:10 [已关闭问题] 关闭于 2013-12-23 21:03

有三个文件:/index.php、/js/zeai_index.js、/ajax/t.php

问题图片:

index.php部分相关代码:

<div class="main3">
    <div class="main3bs">
      <div class="main3T">
    <div class="main3T1">
       <div class="main3T1-1" id="ta"></div>
 </div>
 <div class="main3-2"></div>
    <div class="main3T2">
   <div class="main3T2-1">
<a href="###" id="t1" onclick="tA(this,0,<?php if(empty($cook_userid)){echo 0;}else{echo $cook_userid;} ?>,<?php if(empty($cook_sex)){echo 0;}else{echo $cook_sex;}?>)">上海</a>
<?php
//$id1 = 28;//表示上海大类
$rt=$db->query("SELECT id2,title FROM ".__TBL_AREA__." WHERE id1=28 AND id2>0 AND id3=0 AND flag=1  ORDER BY rand() LIMIT 9");
$total = $db->num_rows($rt);
if ($total == 0) {
 echo "暂无地区";
} else {
        for($p=1;$p<=$total;$p++) {
  $rows = $db->fetch_array($rt);
  if(!$rows) break;
  $id2    = $rows[0];
  $title  = $rows[1];
  $areas = $areas.$id2.',';
?>
<a href="###" id="t<?php echo $p+1; ?>" onclick="tA(this,<?php echo $id2; ?>,<?php if(empty($cook_userid)){echo 0;}else{echo $cook_userid;} ?>,<?php if(empty($cook_sex)){echo 0;}else{echo $cook_sex;}?>)"><?php echo $title; ?></a>
<?php }} ?>
    </div>
   <div class="main3T2-2"><a href="./tuijian.php" target="_blank">更多城区>></a></div>
 </div>
</div>
</div>
<div class="main3C">
  <div class="main3C1" id="t1t">
 <div class="main3C1s">
   <a href="javascript:void(0)" class="showsex12ed" id="sex12" onclick="tB(1,2,0)">显示女生</a>
   <a href="javascript:void(0)" class="showsex12" id="sex11" onclick="tB(1,1,0)">显示男生</a>
 </div>
 <div class="main3C1a"><a href="./my/push_index.php" target="_blank">申请首页推荐</a></div>
  </div>
  <div class="main3C2" id="t1c"><img src="images/loading.gif" width="16" height="16" alt="上海交友网" /> Loading...</div>
 <div class="clear"></div>
<?php
      $areas1=substr($areas,0,-1);
      $areas2=explode(',',$areas1);
      $len=count($areas2);
      for($s=0;$s<$len;$s++) {
      $id2  = $areas2[$s];
?>
  <div class="main3C1" id="t<?php echo $s+2;?>t">
 <div class="main3C1s">
   <a href="javascript:void(0)" class="showsex12ed" id="sex<?php echo $s+2;?>2" onclick="tB(<?php echo $s+2;?>,2,<?php echo $id2;?>)">显示女生</a>
   <a href="javascript:void(0)" class="showsex12" id="sex<?php echo $s+2;?>1" onclick="tB(<?php echo $s+2;?>,1,<?php echo $id2;?>)">显示男生</a>
 </div>
 <div class="main3C1a"><a href="./my/push_index.php" target="_blank">申请首页推荐</a></div>
  </div>
  <div class="main3C2" id="t<?php echo $s+2;?>c"><img src="images/loading.gif" width="16" height="16" alt="上海交友网" /> Loading...</div>
<div class="clear"></div>
<?php } ?>
<script>tA(this.t1,0);tB(1,2,0);</script>
</div>
<div class="clear"></div>
</div>

zeai_index.js部分相关代码:

function tA(n,id2,cook_userid,cook_sex) {
var obj_id,obj_t,obj_c;
for(var i=1; i<=10; i++){
id="t"+i;
obj_id = $(id);
obj_t  = $(id+'t');
obj_c  = $(id+'c');
if (id==n.id){
createXML();
xmlHttp.open("POST",ajxpath+'t'+ajxext+'i='+i+'&id2='+id2,true);
xmlHttp.onreadystatechange = tDateFeedA;
xmlHttp.send(null);
if (cook_userid==''){
$('sex'+i+'2').className="showsex12ed";
$('sex'+i+'1').className="showsex12";
}else{
if(cook_sex==1){
$('sex'+i+'2').className="showsex12ed";
$('sex'+i+'1').className="showsex12";
}else if(cook_sex==2){
$('sex'+i+'1').className="showsex12ed";
$('sex'+i+'2').className="showsex12";
}
}
obj_id.className="areaed";
obj_t.style.display = obj_c.style.display = "block";
}else{
obj_id.className="area";
obj_t.style.display = obj_c.style.display = "none";
}
}
}

function tB(i,sex,id2) {
createXML();
xmlHttp.open("POST",ajxpath+'t'+ajxext+'i='+i+'&sex='+sex+'&id2='+id2,true);
xmlHttp.onreadystatechange = tDateFeedA;
xmlHttp.send(null);
if (sex==1){
$('sex'+i+'1').className="showsex12ed";
$('sex'+i+'2').className="showsex12";
}else{
$('sex'+i+'2').className="showsex12ed";
$('sex'+i+'1').className="showsex12";
}
}

function tDateFeedA(){
if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
var returndate;
returndate = xmlHttp.responseText;
s = returndate.split("|ZEAI|");
c = s[0];
i = s[1];
a = s[2];
var obj_c  = $("t"+i+'c');
obj_c.innerHTML = c;
$("ta").innerHTML = a;
}
}

t.php部分相关代码:

    $Uhouse           = $rows['house'];
    $Utag             = $rows['tag'];
    $Uheigh           = $rows['heigh'];
    $Uweigh           = $rows['weigh'];
       $Ubirthday = $value->getage($Ubirthday);$Uage = ($Ubirthday > 0)?$Ubirthday.'岁':'';
    $Uheigh           = ($Uheigh>140 && $Uheigh<260)?','.$Uheigh.'厘米':'';
    $Uweigh           = ($Uweigh>30 && $Uweigh<120)?','.$Uweigh.'公斤':'';
       $Uarea  = ','.$value->getareap($Uprovince.'|'.$Ucity.'|'.$Uarea);
    $Uedu    = (!empty($Uedu))?','.$value->getextvalue('edu',$Uedu):'';
    $Upay    = (!empty($Upay))?','.$value->getextvalue('pay',$Upay):'';
    $uaboutus         =' '.gylsubstr(badstr(strip_tags(stripslashes($rows['aboutus']))),20,0,"utf-8",true);
    $Uhref = $_IAEZ['user_2domain'].'/'.$Uid;
    ?>
<div class="main3C2L">
 <div class="main3C2p"><?php echo Zeai_cnPhoto_sOut($Usex,$Uphoto_s,$Uphoto_f,$Uphoto_pass,110,$Uhref,0,$Uid); ?></div>
 <div class="main3C2t">
   <div class="main3C2t1"><a href=<?php echo $Uhref; ?> class="sexico<?php echo $Usex; ?>" target="_blank"><?php echo $Unickname; ?></a></div>
   <div class="main3C2t2"><?php echo $Uage,$Uarea,$Uheigh,$Uedu,$Upay; ?></div>
   <div class="main3C2t3"><?php echo $uaboutus; ?></div>
   <div class="main3C2t4"><a href="<?php echo $_IAEZ['user_2domain'].'/'.$Uid; ?>">查看详情>></a></div>
 </div>
</div>
<?php }} ?>   
<div class="clear"></div>
<?php }echo '|ZEAI|'.$i;echo '|ZEAI|';
$rtm=$db->query("SELECT title FROM ".__TBL_AREA__." WHERE id1=28 AND id2=".$id2." AND id3=0 AND flag=1");
$rowsm = $db->fetch_array($rtm);
$Utitle  = $rowsm[0];
echo $Utitle;
ob_end_flush();?>

现在问题是这样的,其它地区功能都能正常显示,只是第一个链接,默认打开也是正常显示,点击链接:<a href="###" id="t1" onclick="tA(this,0,<?php if(empty($cook_userid)){echo 0;}else{echo $cook_userid;} ?>,<?php if(empty($cook_sex)){echo 0;}else{echo $cook_sex;}?>)">上海</a> ,始终无法在ID="ta"的div里显示,浏览器总是提示:Error:'null' is null or not an object 跪求各位路过高人指点,万分感激!

问题补充:

有没有大仙走过,等了一晚上了,汗~

shjy5的主页 shjy5 | 初学一级 | 园豆:3
提问于:2013-12-21 12:05
< >
分享
所有回答(2)
0

你把<a href="###" id="t1" onclick="tA(this,0,<?php if(empty($cook_userid)){echo 0;}else{echo $cook_userid;} ?>,<?php if(empty($cook_sex)){echo 0;}else{echo $cook_sex;}?>)">上海</a>

的前端代码发给我。就是html代码。

angelshelter | 园豆:9676 (大侠五级) | 2013-12-22 10:06

@shjy5: 算了,沟通有障碍。

支持(0) 反对(0) angelshelter | 园豆:9676 (大侠五级) | 2013-12-22 11:12

@angelshelter:他说的意思是把生成后的html代码发给他吧  人家好心帮你  不能这样吧  

支持(0) 反对(0) 灬达 | 园豆:157 (初学一级) | 2013-12-22 21:36
0

好长的代码

jerry-Tom | 园豆:4077 (老鸟四级) | 2013-12-23 13:41
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册