未捕获的ReferenceError:手机未定义javascript错误

时间:2022-11-07 08:52:12

When I am a clicking on Phone number it displaying me that. This function is defined. How can I resolve following error and thanks in advance!

当我点击电话号码时,它会向我显示。此功能已定义。如何解决以下错误并提前致谢!

Below is given my code:

下面给出了我的代码:

<div class="product-label">
    <h4><?php echo $p["FullName"];?>, <?php echo $p["Area"];?></h4>
    <h5 style="font-size:14px"><span class="icon-calendar"></span>  <?php echo $p["SaleDate"];?></h5>
    <h5 style="font-size:14px"><span class="icon-clock"></span>
    <?php for($i = 0; $i < count($p['StartTime']); $i++):?>
      <?php echo $p['StartTime'][$i].'-'.$p['EndTime'][$i]?>
    <?php endfor;?>
    </h5>
    <div data-balloon-length="fit" data-balloon=" <?php echo $p["Address1"].'-'.$p["Postal"];?>" data-balloon-pos="up">
        <h5 style="font-size:14px;width: 100%;text-overflow: ellipsis;overflow: hidden;white-space: nowrap;">
            <span class="icon-home"></span>  
            <?php echo $p["Address1"].'-'.$p["Postal"];?>
        </h5>
    </div>
    <div data-balloon-length="fit" data-balloon=" <?php echo $p["description"];?>" data-balloon-pos="up">
        <h5 style="font-size:14px;width: 100%;text-overflow: ellipsis;overflow: hidden;white-space: nowrap;">
            <span class="icon-file"></span>  
            <?php echo $p["description"];?>
        </h5>
    </div>
    <h5 style="font-size:14px;width: 100%;text-overflow: ellipsis;overflow: hidden;white-space: nowrap;">
        <span class="icon-file"></span>  
        <a onclick="phone(<?php echo $p['checkbox'][0]['UniqueID']?>,this);"  id="thumb<?php echo $p['checkbox'][0]['UniqueID']?>" style="cursor:pointer;color:#000"><u>Phone Number</u></a>
    </h5>
</div>

Javascript code:

Javascript代码:

function phone(id,ths){
    var email = '';

    if(<?=$loggedin?>){
        email = <?php $email;?>;
    }
    else{
        email = $("#cmail").val();
    }

    alert(email);
}

1 个解决方案

#1


-1  

You are getting the error just because of:

您只是因为以下原因而得到错误:

if(<?=$loggedin?>){
   email = <?php $email;?>;
}

Don't know where you define this? $loggedin ?

不知道你在哪里定义这个? $ loggedin?

Second, <?php $email;?> this will do nothing here.

第二,<?php $ email;?>这里什么都不做。

Basic Example:

基本示例:

function phone(id,ths){
    alert(id);
    alert(ths);             
}
<a onclick="phone('111',this);" href="javascript:void(0);">Phone Number</a>  

Also note that, your code is working, if i remove this code block:

另请注意,如果我删除此代码块,您的代码将正常工作:

if(<?=$loggedin?>){
   email = <?php $email;?>;
}

#1


-1  

You are getting the error just because of:

您只是因为以下原因而得到错误:

if(<?=$loggedin?>){
   email = <?php $email;?>;
}

Don't know where you define this? $loggedin ?

不知道你在哪里定义这个? $ loggedin?

Second, <?php $email;?> this will do nothing here.

第二,<?php $ email;?>这里什么都不做。

Basic Example:

基本示例:

function phone(id,ths){
    alert(id);
    alert(ths);             
}
<a onclick="phone('111',this);" href="javascript:void(0);">Phone Number</a>  

Also note that, your code is working, if i remove this code block:

另请注意,如果我删除此代码块,您的代码将正常工作:

if(<?=$loggedin?>){
   email = <?php $email;?>;
}