dstbp22002 2013-08-12 11:36
浏览 35

单击复选框 - 动态创建的内容时,更改按钮的颜色

I am listing down all the departments in my db like this.

Select * from department

and I am using a pagination to list down departments. Only 8 departments will be listed.

<?php 

 while($row_department = mysql_fetch_array($result))
{
       ?>
 <?php echo $row_department['department_name'];?>
   <div>
      <table width="500" border="0" cellspacing="1" cellpadding="1">
      <tr>
        <td>Department Description</td>
         <td>&nbsp;<textarea name="txt_department_description" cols="50" rows="7" id="txt_department_description"><?php echo $row_department['department_description']; ?>                   </textarea></td>
      </tr>
             <tr>
             <td width="341">&nbsp;<input type="checkbox" name="option"  id="option" onClick="javascript:enableButton();">Click to Delete Department<br></td>
             </tr>
            <tr>
            <td>&nbsp;<input name="enter_department" id="enter_department" type="submit" value="Update Department" /><input name="Reset" type="reset" value="Cancel" />            
  <input name="delete_department" id="delete_department" type="submit" value="Delete Department" />
 </td>
       </tr>
           </table>
           </div>
            <?php } ?>

by this page user can Update or Delete selected departments. Delete button will be enable when user click on the Check Box that above listed. This javascript function will be called onclick event.

<script>
 function enableButton() {
    if(document.getElementById('option').checked){
    alert('1');
    document.getElementById('delete_department').disabled='';
    document.getElementById('enter_department').disabled='true';
    document.getElementById('enter_department').style.backgroundColor ='Grey';
    document.getElementById('delete_department').style.backgroundColor = 'green';
} else {
    document.getElementById('delete_department').disabled='true';
    document.getElementById('enter_department').style.backgroundColor ='';
    document.getElementById('delete_department').style.backgroundColor = '';
}
}   
</script>

when we click on the checkbox on first record, function is working, but if we try to click the second record checkbox, function is not working.

Can anyone please look in this? anything I am doing wrong.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥15 stable diffusion
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿