dsfb20227 2015-06-11 07:59 采纳率: 0%
浏览 35

css选中复选框

I want to display the checkbox in while loop and nned to apply the CSS based on $status value.If status=open in database open should be checked and vice versa for status='Close' .I have CSS for each and every row based on id.I created random id in PHP variable $a.

Now This is working only for status='open' which is checked in if condition.

     $a=0;
         while($sfet=mysql_fetch_assoc($sql1))
         {
              echo ('<style>

      .ck-button'.$a.' {
       margin:0px;
       background-color:#EFEFEF;
       border-radius:4px;
      border:1px solid #D0D0D0;
      overflow:auto;
       float:left;
       }

    .ck-button'.$a.' #label'.$a.' {
    float:left;
    width:4.0em;
    }
    .ck-button'.$a.' #label'.$a.' #span'.$a.' {
     text-align:center;
     padding:3px 0px;
      display:block; 
     border-radius:4px;
      }

    .ck-button'.$a.' #label'.$a.' input {
     position:absolute;
     top:-20px;
     }
    input#o1'.$a.':checked + #span'.$a.' {
    background-color: green;
     color: #fff;
   }
  input#o2'.$a.':checked + #span'.$a.' {
   background-color: red;
  color: #fff; 
   }
  input#o3'.$a.':checked + #span'.$a.' {
  background-color: orange;
   color: #fff;
   }

 .ck-button'.$a.' #label'.$a.':hover #o1'.$a.' + #span'.$a.' {
 background-color:green;
 }
 .ck-button'.$a.' #label'.$a.':hover #o2'.$a.' + #span'.$a.' {
  background-color:red;  
 }
 .ck-button'.$a.' #label'.$a.':hover #o3'.$a.' + #span'.$a.' {
  background-color:orange;
  }
   </style>'); 
           $title=$sfet['title'];
           $c_name=$sfet['c_name'];
           $e_first_name=$sfet['e_first_name'];
           $status=$sfet['status'];
           $req_id=$sfet['req_id'];
           $e_id=$sfet['e_id'];
           echo '<tr><td><a href="broadcast_detail.php?req_id='.$req_id.'" class="astext">'.$title.'</a></td><td>'.$c_name.'</td><td>'.$e_first_name.'</td>';
            $count="select * from resume where e_id='$e_id' and req_id='$req_id'";
            $count1=mysql_query($count);
            $num=mysql_num_rows($count1);
           echo '<td>'.$num.'</td>';
           if($status=='Open')
           {
           echo"<td><div class='ck-button".$a."'><label id='label".$a."'><input type='radio' name='sta_choice".$a."' id='o1".$a."' onclick=demo('Open',".$req_id."); value='Open' checked><span id='span".$a."'>Open</span></label></div>";
            echo"<div class='ck-button".$a."'><label id='label".$a."'><input type='radio' name='sta_choice".$a."' id='o2".$a."' value='Close' onclick=demo('Close',".$req_id.");><span id='span".$a."'>Close</span></label></div>";
             echo"<div class='ck-button".$a."'><label id='label".$a."'><input type='radio' name='sta_choice".$a."' id='o3".$a."' value='Hold' onclick=demo('Hold',".$req_id.");><span id='span".$a."'>Hold</span></label></div></td><br><br>";

           }
           else if($status=='close'){


             echo"<td><div class='ck-button".$a."'><label id='label".$a."'><input type='radio' name='sta_choice".$a."' id='o1".$a."' onclick=demo('Open',".$req_id."); value='Open'><span id='span".$a."'>Open</span></label></div>";
              echo"<div class='ck-button".$a."'><label id='label".$a."'><input type='radio' name='sta_choice".$a."' id='o2".$a."' value='Close' onclick=demo('Close',".$req_id.");><span id='span".$a."' checked>Close</span></label></div>";
               echo"<div class='ck-button".$a."'><label id='label".$a."'><input type='radio' name='sta_choice".$a."' id='o3".$a."' value='Hold' onclick=demo('Hold',".$req_id.");><span id='span".$a."'>Hold</span></label></div></td><br><br>";

           }
  $a++;
  }
  • 写回答

1条回答 默认 最新

  • douzhi3454 2015-06-11 08:06
    关注

    It seems to me that the if statement is faulty, it echo's the exact same thing, thus not resulting in any changes if the database option changes.

    Also Open is with a capital letter, and close is not.

    评论

报告相同问题?

悬赏问题

  • ¥15 为什么apriori的运行时间会比fp growth的运行时间短呢
  • ¥15 帮我解决一下膳食平衡的线性规划模型的数据实例
  • ¥40 万年历缺少农历,需要和阳历同时显示
  • ¥250 雷电模拟器内存穿透、寻基址和特征码的教学
  • ¥200 比特币ord程序wallet_constructor.rs文件支持一次性铸造1000个代币,并将它们分配到40个UTXO上(每个UTXO上分配25个代币),并设置找零地址
  • ¥15 关于Java的学习问题
  • ¥15 如何使用chatgpt完成文本分类任务?
  • ¥15 已知速度v关于位置s的等式,怎么转化为已知位置求速度v的等式
  • ¥15 我有个餐饮系统,用wampserver把环境配置好了,但是后端的网页却进去,是为什么,能不能帮远程一下?
  • ¥15 R运行没有名称为"species"的插槽对于此对象类"SDMmodelCV"