javascript - 想在html里面加个判断,该怎么加?
PHP中文网
PHP中文网 2017-04-11 10:59:23
0
1
712

我想在这句话上面加个判断,如果adcdeal_suc值为-1的话在页面变色可以点击,跳出一个弹框,如果不是-1就和平时一样不变色,,求大神说说怎么做啊,源代码我也贴出来求解答

<TD align=middle ><a href="javascript:adcdeal_suc();"><font color="#6633CC">{adcdeal_suc}</TD>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
        <title>互动平台</title>
<script language="javascript" src="/js/selection.js"></script>
<script language="javascript" src="/js/dropdownlist.js"></script>
<script language="javascript" src="/js/zsedu.js"></script>
<script language="javascript" src="/admin/js/search.js"></script>
        <style type="text/css">
<!--
body,td,th {
    font-size: 12px;
    color: #000000;
}
body {
    background-color: #ffffff;
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
a:link {
    color: #000000;
    text-decoration: none;
}
a:visited {
    text-decoration: none;
    color: #000000;
}
a:hover {
    text-decoration: none;
    color: #003399;
}
a:active {
    text-decoration: none;
    color: #000000;
}
-->
        </style>
        <link href="/admin/css/css.css" rel="stylesheet" type="text/css">        
        <style type="text/css">
<!--
.STYLE2 {color: #FF0000}
-->
        </style>
    </head>

    <body>
    <form name="form1" action="" method="post">
        <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td height="39" background="/admin/images/images_30.gif">
                    <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td height="39" background="/admin/images/images_30.gif">
                                <table width="100%" height="36" border="0" cellpadding="4" cellspacing="0">
                                    <tr>
                                        <td width="1%" align="right" valign="bottom">&nbsp; </td>
                                        <td width="33%" align="right" valign="bottom"
                                            class="title_edu">
                                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                <tr>
                                                    <td width="30" align="left" class="title01">&nbsp; </td>
                                                    <td align="left" valign="bottom" class="title01"> 业务定制 </td>
                                                </tr>
                                            </table>
                                        </td>
                                        <td width="66%" align="right">
                                            <span class="fontred">
                                                <img src="/admin/images/index_dot.gif" width="16" height="17" align="absmiddle"> 您的位置:
                                            </span>业务管理 -&gt; CP业务订购管理
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td width="11" align="right" background="/admin/images/images_30.gif">
                                <img src="/admin/images/images_35.gif" width="11" height="39" alt="">
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td height="100%">
                                <p class="tScroll01">
                                    <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td align="center" valign="top">
                                                <table border="0"><tr><td height="8"></td></tr></table>
                                                <table width="98%" border="0" cellpadding="3" cellspacing="1" bgcolor="#2467C2">
                                                    <TR>
                                                        <td width="12%" align="right" bgcolor="#E5F2FF" class="font5"><span style="color:#f00">*</span>地  区:<input type="hidden" value="{roleType}" id="roleType"/></td>
                                                        <td width="22%" align="left" bgcolor="#FFFFFF" ><select name="area_id" class="inbox01" onchange="getTownListDefault(null);">{areaOption}</select></td>
                                                        <td width="12%" align="right" bgcolor="#E5F2FF" class="font5">县区:</td>
                                                        <td width="22%" align="left" bgcolor="#FFFFFF" ><select name="town_id" class="inbox01" id="town_id" onchange="getSchoolListDefault(null);">{townOption}</select></td>
                                                        <td width="10%" align="right" bgcolor="#E5F2FF" >
                                                            学校:<img src="/admin/images/btn_search.gif" border="0" align="absmiddle" onclick="osearch('school_id');">
                                                        </td>
                                                        <td width="22%" align="left" bgcolor="#FFFFFF" colspan="2"><select name="school_id" class="inbox01" id="school_id">{schoolOption}</select></td>                                                        
                                                    </TR>
                                                    <TR>
                                                        <td width="12%" align="right" bgcolor="#E5F2FF" >所属公司:</td>
                                                        <td width="22%" align="left" bgcolor="#FFFFFF" ><select name="cp_id" class="inbox01" onchange="getServiceList(this.value);">{cp_options}</select></td>                                                       
                                                        <td width="12%" align="right" bgcolor="#E5F2FF" >业  务:<input type="hidden" value="{tran_id}" id="tran_id" /> </td>
                                                        <td width="22%" align="left" bgcolor="#FFFFFF" ><span id="ajax_p"><select name="transaction" class="inbox01">{transaction}</select></span></td>
                                                        <td width="10%" align="right" bgcolor="#E5F2FF" >学生姓名:</td>
                                                        <td width="22%" align="left" bgcolor="#FFFFFF" ><input type="text" value="{nick_name}" class="inbox01" id="nick_name" name="nick_name"/></td>
                                                    </tr>
                                                     <TR>
                                                         <td align="right" bgcolor="#E5F2FF" >手机号码:</td>
                                                        <td align="left" bgcolor="#FFFFFF"><input type="text" value="{mobile}" name="mobile" class="inbox01" maxlength=11 /></td>
                                                         <td align="right" bgcolor="#E5F2FF" >订购状态:</td>
                                                        <td align="left" bgcolor="#FFFFFF"><span id="ajax_p"><select name="del" class="inbox01">{del_selections}</select></span></td>
                                                        <td align="right" bgcolor="#E5F2FF">同步状态:</td>
                                                        <td align="left" bgcolor="#FFFFFF"><span id="ajax_p"><select name="adc" class="inbox01">{adc_selections}</select></span></td>
                                                    </TR>
                                                    <TR>
                                                        <td  align="right" bgcolor="#E5F2FF" >创建日期:</td>
                                                        <td align="left" bgcolor="#FFFFFF" colspan="3">
                                                            <input name="begintime" value="{begintime}" type="text"   onClick="return selectDate2('begintime','form1')" style="cursor:hand" size="13" readonly>
                                                            至
                                                            <input name="endtime" value="{endtime}" type="text"  onClick="return selectDate2('endtime','form1')" style="cursor:hand" size="13" readonly>
                                                            <a href="#" onclick="javascript:document.form1.begintime.value='';document.form1.endtime.value='';">清空</a>
                                                        </td>
                                                        <td align="right" bgcolor="#E5F2FF" >本次修改原因:</td>
                                                        <td align="left" bgcolor="#FFFFFF">
                                                        <input type="text" value="" name="changeresult" class="inbox01" maxlength="100" />
                                                        </td>
                                                    </TR>
                                                        <tr>
                                                        <td colspan="6" align="right" bgcolor="#FFFFFF" class="font5">
                                                             <input name="btnopen1" type="button" class="btn01" onFocus="this.blur()" onClick="businessQuery()"
                                                                onMouseOver="this.className='btn02'" onMouseOut="this.className='btn01'" value="  查 询  ">
                                                          <!--input name="btnopen2" type="button" class="btn01" onFocus="this.blur()" onClick="businessAdd()"
                                                                onMouseOver="this.className='btn02'" onMouseOut="this.className='btn01'" value="业务关系导入"-->
                                                         <input name="btncancel1" type="button" class="btn01" onFocus="this.blur()" onClick="businessExport()"
                                                                onMouseOver="this.className='btn02'" onMouseOut="this.className='btn01'" value="业务关系导出">
                                                          <!--input name="btncancel2" type="button" class="btn01" onFocus="this.blur()" onClick="businessBook()"
                                                                onMouseOver="this.className='btn02'" onMouseOut="this.className='btn01'" value="用户业务订购">
                                                          <input name="exportData" type="button" class="btn01" onFocus="this.blur()" onClick="businessCancel()"
                                                                onMouseOver="this.className='btn02'" onMouseOut="this.className='btn01'" value="用户业务取消"-->
                                                    </tr>
                                                </table>
                                                <table border="0">
                                                    <tr>
                                                        <td height="8"></td>
                                                    </tr>
                                                </table>
                                                <table width="98%" border="0" cellpadding="2" cellspacing="1" class="mainbd01">
                                                    <tr class=mainlisttitle>
                                                        <TD width="4%" align=middle bgcolor="#B3D7FF">
                                                            <INPUT onClick="CheckAll(form1)" type=checkbox value=checkbox name=chkall>全选
                                                        </TD>
                                                        <TD width="4%" align=middle bgcolor="#B3D7FF">地区</TD>
                                                        <TD width="4%" align=middle bgcolor="#B3D7FF">县区</TD>
                                                        <TD width="6%" align=middle bgcolor="#B3D7FF">手机号码</TD>
                                                        <TD width="5%" align=middle bgcolor="#B3D7FF">学生姓名</TD>
                                                        <TD width="10%" align=middle bgcolor="#B3D7FF">学生班级</TD>
                                                        <TD width="7%" align=middle bgcolor="#B3D7FF">学生编号</TD>
                                                        <TD width="17%" align=middle bgcolor="#B3D7FF">业务名称</TD>
                                                        <TD width="10%" align=middle bgcolor="#B3D7FF">所属公司</TD>
                                                        <TD width="12%" align=middle bgcolor="#B3D7FF">日期</TD>
                                                        <TD width="7%" align=middle bgcolor="#B3D7FF">套餐类型</TD>
                                                        <TD width="6%" align=middle bgcolor="#B3D7FF">订购状态</TD>
                                                        <TD width="6%" align=middle bgcolor="#B3D7FF">同步状态</TD>
                                                    </tr>
                                                    {row}
                                                    <tr class="mainoutbg" onMouseOver="this.className='mainoverbg'" onMouseOut="this.className='mainoutbg'">
                                                        <TD align=middle >{checkbox}</TD>
                                                        <TD align=middle >{area_name}</TD>
                                                        <TD align=middle >{town_name}</TD>
                                                        <TD align=middle >{phone}</TD>
                                                        <TD align=middle >{username}</TD>
                                                        <TD align=middle >{stu_class}</TD>
                                                        <TD align=middle >{stu_sequence}</TD>
                                                        <TD align=middle ><a href="javascript:tran_name('{phone}','{confirm_sms}','{sendtime}','{reply_sms}','{reply_time}','{type}','{sendconfrimsms_again}','{customer_id}','{area_id}');"><font color="#6633CC">{tran_name}</font></a></TD>
                                                        <TD align=middle >{cp_name}</TD>
                                                        <TD align=middle >{dt}</TD>
                                                        <TD align=middle >{fee}</TD>
                                                        <TD align=middle >{del}</TD>
                                                        <TD align=middle >
                                                            {if form1.adcdeal_suc.value == -1}
                                                            <a href="javascript:adcdeal_suc();"><font color="#6633CC">{adcdeal_suc}</font></a>
                                                            {else}
                                                            <font>{adcdeal_suc}</font></a>
                                                            {/if}
                                                        </TD>
                                                    </tr>
                                                    {row}
                                                     <tr class=mainoutbg onmouseover="this.className='mainoverbg'" 
                                                                    onmouseout="this.className='mainoutbg'" style="display:{hidden}">
                                                      <TD align=center colspan="13" bgcolor="#FFFFFF" ><font color="blue">没 有 记 录 !</font></TD>
                                                      </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </p>
                            </td>
                            <td width="4" background="/admin/images/images_48.gif"></td>
                        </tr>
                        <tr>
                            <td height="40" align="right" class="basebtnbg">
                                {roll}
                            </td>
                            <td background="/admin/images/images_48.gif"></td>
                        </tr>
                    </table>
                </td>
            </tr>
            
        </table>
        </form>
    </body>
</html>
<script language="javascript" src="/cp/system/js/cp.js"></script>
<script language="javascript">
function businessQuery(){
    if(form1.mobile.value=="" && (form1.area_id.value==""||form1.area_id.value=="-1")){
        alert("请选择地区!");
        return;
    }
    if(form1.begintime.value!=""&&form1.endtime.value!=""){
        if(form1.begintime.value>form1.endtime.value){
            alert("截止日期必须在起始日期后!");
            form1.begintime.value="";
            form1.endtime.value="";
            return;
        }
    }
    form1.action="/cptransaction.do?action=query";
    form1.submit();
}

function businessExport(){
    if(form1.area_id.value==""||form1.area_id.value=="-1"){
        alert("请输入地区!");
        return;
    }
    if(form1.begintime.value!=""&&form1.endtime.value!=""){
    if(form1.begintime.value>form1.endtime.value){
        alert("截止日期必须在起始日期后!");
        form1.begintime.value="";
        form1.endtime.value="";
        return;
    }
    }
    form1.action="/cptransaction.do?action=businessexport";
    form1.submit();
}

var xmlHttp;
function getServiceList(cp_id){
    var service_id = document.getElementById("tran_id").value;
    if(cp_id !=0){
        var url = "/cptransaction.do?action=getServiceList&cp_id="+cp_id+"&transaction="+service_id;
        if (window.ActiveXObject) {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        } else if (window.XMLHttpRequest) {
            xmlHttp = new XMLHttpRequest();
        }    
        xmlHttp.onreadystatechange = onStateChange;
        xmlHttp.open("GET",url,true);
        xmlHttp.send(null);
    }else{
        document.getElementById("ajax_p").innerHTML="<select name='transaction' class='inbox01'><option value='-1'>全部</option></select>";
    }    
}                
function onStateChange(){
     if(xmlHttp.readyState == 4){
        if(xmlHttp.status == 200){
            var result = xmlHttp.responseText;
            if( result != ""){
                var html = "<select name='transaction' class='inbox01'>"+result+"</select>";
                document.getElementById("ajax_p").innerHTML=html;        
            }
        }
     }
   }

function businessBook(){
    if(form1.transaction.value == "-1"){
        alert("请选择业务!");
        form1.transaction.focus();
        return;
    }
    var j=0;
    for(i=0;i<document.form1.elements.length;i++){
        if(document.form1.elements[i].name=="checkbox"){
            var o=document.form1.elements[i];
            if(o.checked==true)
                j++;
          }
    }
    if(j==0){
        alert("请选择要订购的用户");
        return;
    }
    if(confirm("确定要订购该业务吗?") == true){
        form1.action="/cptransaction.do?action=businessbook&flag=1";
        form1.submit();
    }
}

function businessCancel(){
    var j=0;
    for(i=0;i<document.form1.elements.length;i++){
        if(document.form1.elements[i].name=="checkbox"){
            var o=document.form1.elements[i];
            if(o.checked==true)
                j++;
          }
    }
    if(j==0){
        alert("请选择要取消的用户");
        return;
    }
    if(confirm("确定要取消该业务吗?") == true){
        form1.action="/cptransaction.do?action=businesscancel&flag=1";
        form1.submit();
    }
}

function businessAdd(){
    var roleType = document.getElementById("roleType").value;
    if( roleType=='3'){
        form1.action="/cptransaction.do?action=sabusinessimportinit";
    }else{
        form1.action="/cptransaction.do?action=businessimportinit";
    }
    form1.submit();
}

function CheckAll(form)
  {
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.name == 'checkbox' )
       e.checked = form.chkall.checked;
    }
  }
function initServiceSelect(){
    var cp_id = document.getElementById("cp_id").value;
    getServiceList(cp_id);
}

function SAExport(){
        form1.action="/cptransaction.do?action=sabusinessimportinit";
        form1.submit();
    
}
function tran_name(phone,confirm_sms,sendtime,reply_sms,reply_time,type,sendconfrimsms_again,customer_id,area_id){
    window.open('/cptransaction.do?action=tran_name&phone='+phone+"&confirm_sms="+confirm_sms+
    "&sendtime="+sendtime+"&reply_sms="+reply_sms+"&reply_time="+reply_time+"&type="+type+"&sendconfrimsms_again="+sendconfrimsms_again+"&customer_id="+customer_id+"&area_id="+area_id,'查看业务','width=800,height=380,top=150,left=300');
}
function adcdeal_suc(){
   if(suc=="-1"){
    window.open('/cptransaction.do?action=adcdeal_result&adcdeal_result='+adcdeal_result+'&id='+id,'失败原因','width=500,height=380,top=150,left=400');    
    }else{
        
    }
}
</script>
PHP中文网
PHP中文网

认证高级PHP讲师

répondre à tous(1)
小葫芦

你可以根据adcdeal_suc的值是否为-1来给元素动态的添加一个class,比如active,接下来只要操作active就可以了,具体的三目运算表达式如果有问题,你看情况自己修改

<a href="javascript:void(0)" class="{adcdeal_suc == -1?'active':''}">

css中:

a.active{
  color:字体颜色;
  background:背景颜色;
}

js中:

$(document).on('click','a.active',function(){
   //跳出弹框
});
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal