function c1{--->>>function c1(){

解决方案 »

  1.   

    还有一个小问题,如何列举上面程序里的<table>里的所有<TR>对象?就是要写<script> function c1{

                  list1.style.background='#FFFFCC';
                  list2.style.background='#FFFFCC';
                  .....(由于list 的个数是动态生成的所以编写时无法确定到底到list几 }</script>假设下面<table>
    <tr id=list1>
    <tr id=list2>
    <tr id=list3>....动态生成
      

  2.   

    <tr onclick="cl(this);">
    function cl(obj)
    {
      obj.style.backgroundColor="#cccccc";
    }
      

  3.   


    晕,看来还是把问题写全的好:要求:点表格里的某一行时,颜色变掉。大概程序:<script> function c1(cor){

    otable.style.backgroundColor="#cccccc"; //第一步,把整个表格的所有行都变原色 cor.style.background='#FFFFFF'; //第二步,把点到的那一行变希望的颜色
    }</script></head>
    <body>  <table border="1" width="400" cellspacing="0" cellpadding="0" id=otable bgcolor="#cccccc">
        <tr onclick="c1(this);">
          <td width="49"> </td>
        </tr>
        <tr onclick="c1(this);">
          <td width="49"> </td>
        </tr>
      </table>
    现在问题是当TR有指定颜色时,整个表格的BG颜色就不对他起作用了。所以第一步要改成:列举所有的TR,他们的BG都变原色。
    你刚才写的程序的确是变色了,但关键是当点其他行时,他要变回原色
      

  4.   

    <script>
    var aaa=null; function c1(cor){
    cor.style.background='#FFFFFF'; //第二步,把点到的那一行变希望的颜色;
    if(aaa!=null) aaa.style.backgroundColor="";
    aaa=cor;
    }</script><body>  <table border="1" width="400" cellspacing="0" cellpadding="0" id=otable bgcolor="#cccccc">
        <tr onclick="c1(this);">
          <td width="49"> </td>
        </tr>
        <tr onclick="c1(this);">
          <td width="49"> </td>
        </tr>
        <tr onclick="c1(this);">
          <td width="49"> </td>
        </tr>
      </table>
      

  5.   

    <script>
    var aaa=null; function c1(cor){
    cor.style.background='#FFFFFF'; //第二步,把点到的那一行变希望的颜色;
    if(aaa!=null) aaa.style.backgroundColor="";
    if(aaa==cor) aaa=null;//加上此句,以控制点击变白,再点击反灰
    else aaa=cor;
    }</script><body>  <table border="1" width="400" cellspacing="0" cellpadding="0" id=otable bgcolor="#cccccc">
        <tr onclick="c1(this);">
          <td width="49"> </td>
        </tr>
        <tr onclick="c1(this);">
          <td width="49"> </td>
        </tr>
        <tr onclick="c1(this);">
          <td width="49"> </td>
        </tr>
      </table>
      

  6.   

    哦,另外还要问一下!!
    function OptionConfirmadd7(){       alert("OK");
           //document.addnew.t_gsje1.focus();  <---- (1)
           return false;
    }
    <form>
    有一个addnew表单内有对象t_gsje1
    </form><form>
    有一个addnew1表单内有对象t_gsje2
    </form>
    以上2个表单都有<input type="submit" value=" 修 改 数 据 " name="B1" onClick="return OptionConfirmadd7();">上面的(1)处,我要实现document.addnew.t_gsje1.focus(); 和document.addnew1.t_gsje2.focus(); 但是程序只写一个OptionConfirmadd7。所以有无这种传对象的方式