0

我正在尝试根据输入中填充的文本来显示或隐藏一些 div。

所以实际上我已经完成了这个功能:

<script type="text/javascript">
function checkdiv()
    {
    var position1= document.getElementById("position1").value;
        if(position1==1)
        {
         document.getElementById("a1").style.visibility = "hidden"                        
        }
        else
        {
         document.getElementById("a1").style.visibility= "visible"                        
        }
        if(position1=="2")
        {
         document.getElementById("a2").style.visibility = "hidden"                        
        }
        if(position1!="2")
        {
         document.getElementById("a2").style.visibility= "visible"                        
        }
        if(position1=="3")
        {
         document.getElementById("a3").style.visibility = "hidden"                        
        }
        if(position1!="3")
        {
         document.getElementById("a3").style.visibility= "visible"                        
        }
         if(position1=="4")
        {
         document.getElementById("a4").style.visibility = "hidden"                        
        }
        if(position1!="4")
        {
         document.getElementById("a4").style.visibility= "visible"                        
        }  
         if(position1=="5")
        {
         document.getElementById("a5").style.visibility = "hidden"                        
        }
        if(position1!="5")
        {
         document.getElementById("a5").style.visibility= "visible"                        
        }
        if(position1=="6")
        {
         document.getElementById("a6").style.visibility = "hidden"                        
        }
        if(position1!="6")
        {
         document.getElementById("a6").style.visibility= "visible"                        
        }
         if(position1=="7")
        {
         document.getElementById("a7").style.visibility = "hidden"                        
        }
        if(position1!="7")
        {
         document.getElementById("a7").style.visibility= "visible"                        
        }
         if(position1=="8")
        {
         document.getElementById("a8").style.visibility = "hidden"                        
        }
        if(position1!="8")
        {
         document.getElementById("a8").style.visibility= "visible"                        
        }          
        if(position1=="9")
        {
         document.getElementById("a9").style.visibility = "hidden"                        
        }
        if(position1!="9")
        {
         document.getElementById("a9").style.visibility= "visible"                        
        }
         if(position1=="10")
        {
         document.getElementById("a10").style.visibility = "hidden"                        
        }
        if(position1!="10")
        {
         document.getElementById("a10").style.visibility= "visible"                        
        }          
        if(position1=="11")
        {
         document.getElementById("a11").style.visibility = "hidden"                        
        }
        if(position1!="11")
        {
         document.getElementById("a11").style.visibility= "visible"                        
        }   
        if(position1=="12")
        {
         document.getElementById("a12").style.visibility = "hidden"                        
        }
        if(position1!="12")
        {
         document.getElementById("a12").style.visibility= "visible"                        
        } 


    }
       checkdiv();  
  </script>

所有这一切都与下表的列Ordre:

<form action="#" method="post">
<table width='100%' id='boxa' align='center' ><thead><tr><th scope='col' width='3%'><strong>CODE CLIENT</strong></th><th scope='col' width='10%'><strong>TITRE</strong></th><th scope='col' width='15%'><strong>POSTE</strong></th><th scope='col' width='3%'><strong>ORDRE</strong></th><th scope='col' width='25%'><strong>DESCRIPTION</strong></th><th scope='col' width='10%'><strong>VU CLIENT</strong></th><th scope='col' width='10%'><strong>VU TIERS</strong></th></tr></thead><tbody> <tr>

        <td>
        <input name="data[1][code_client]" type="text"  id="code_client1" size="5"  onkeyup="clientventilation()" /></td>
        <td><input name="data[1][libelle]" type="text" size="10" id="libelle1" onkeyup="titreventilation()"  /></td>
        <td><input name="data[1][poste]" type="text" value="Principal" size="30" /></td>
        <td><input name="data[1][ordre]" id="position1" type="text" size="2"  onblur="checkdiv()" /></td>
        <td><input name="data[1][description]" type="text" value="Montant de la dette" size="40" /></td><td><select name="data[1][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[1][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>
        <tr>

        <td><input name="data[2][code_client]" type="text" size="5" id="code_client2"  /></td>
        <td><input name="data[2][libelle]" type="text" size="10" id="libelle2"   /></td>
        <td><input name="data[2][poste]" type="text" value="Int&eacute;r&ecirc;ts" size="30" /></td>
        <td><input name="data[2][ordre]" type="text" size="2" id="position2" onblur="checkdiv()" /></td>
        <td><input name="data[2][description]" type="text" value="Int&eacute;r&ecirc;ts (sur soldes des factures d&ucirc;es)" size="40" /></td><td><select name="data[2][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[2][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>

        <tr>

        <td><input name="data[3][code_client]" type="text" size="5" id="code_client3"  /></td>
        <td><input name="data[3][libelle]" type="text" size="10" id="libelle3"  /></td>
        <td><input name="data[3][poste]" type="text" value="Clause p&eacute;nale" size="30" /></td>
        <td><input name="data[3][ordre]" type="text" size="2" id="position3" onblur="checkdiv()" /></td>
        <td><input name="data[3][description]" type="text" value="Clause p&eacute;nale contractuelle" size="40" /></td><td><select name="data[3][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[3][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>
        <tr>

        <td><input name="data[4][code_client]" type="text" size="5" id="code_client4"  /></td>
        <td><input name="data[4][libelle]" type="text" size="10" id="libelle4"  /></td>
        <td><input name="data[4][poste]" type="text" value="Dommages et Int&eacute;r&ecirc;ts" size="30" /></td>
        <td><input name="data[4][ordre]" type="text" size="2" id="position4" onblur="checkdiv()" /></td>
        <td><input name="data[4][description]" type="text" value="Montant des Dommages et Int&eacute;r&ecirc;ts" size="40" /></td><td><select name="data[4][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[4][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>
        <tr>

        <td><input name="data[5][code_client]" type="text" size="5" id="code_client5"  /></td>
        <td><input name="data[5][libelle]" type="text" size="10" id="libelle5"  /></td>
        <td><input name="data[5][poste]" type="text" value="Article 700 du CPC" size="30" /></td>
        <td><input name="data[5][ordre]" type="text" size="2" id="position5" onblur="checkdiv()" /></td>
        <td><input name="data[5][description]" type="text" value="Montant correspondant &agrave; la condamnation" size="40" /></td><td><select name="data[5][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[5][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>
        <tr>

        <td><input name="data[6][code_client]" type="text" size="5" id="code_client6"  /></td>
        <td><input name="data[6][libelle]" type="text" size="10" id="libelle6"  /></td>
        <td><input name="data[6][poste]" type="text" value="Frais AR" size="30" /></td>
        <td><input name="data[6][ordre]" type="text" size="2" id="position6" onblur="checkdiv()" /></td>
        <td><input name="data[6][description]" type="text" value="Montant des frais d'accus&eacute;s r&eacute;ception et de courriers" size="40" /></td><td><select name="data[6][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[6][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>
        <tr>

        <td><input name="data[7][code_client]" type="text" size="5" id="code_client7"  /></td>
        <td><input name="data[7][libelle]" type="text" size="10" id="libelle7"  /></td>
        <td><input name="data[7][poste]" type="text" value="Art. 441-6 CC" size="30" /></td>
        <td><input name="data[7][ordre]" type="text" size="2" id="position7" onblur="checkdiv()" /></td>
        <td><input name="data[7][description]" type="text" value="Article 441-6 du code du commerce" size="40" /></td><td><select name="data[7][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[7][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>
        <tr>

        <td><input name="data[8][code_client]" type="text" size="5" id="code_client8"  /></td>
        <td><input name="data[8][libelle]" type="text" size="10" id="libelle8"  /></td>
        <td><input name="data[8][poste]" type="text" value="Frais et Agios" size="30" /></td>
        <td><input name="data[8][ordre]" type="text" size="2" id="position8" onblur="checkdiv()" /></td>
        <td><input name="data[8][description]" type="text" value="Montant des frais &amp; agios bancaires" size="40" /></td><td><select name="data[8][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[8][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>
        <tr>

        <td><input name="data[9][code_client]" type="text" size="5" id="code_client9"  /></td>
        <td><input name="data[9][libelle]" type="text" size="10" id="libelle9"  /></td>
        <td><input name="data[9][poste]" type="text" value="D&eacute;pens" size="30" /></td>
        <td><input name="data[9][ordre]" type="text" size="2" id="position9" onblur="checkdiv()" /></td>
        <td><input name="data[9][description]" type="text" value="Total calcul&eacute;" size="40" /></td><td><select name="data[9][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[9][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>

        <tr>

        <td><input name="data[10][code_client]" type="text" size="5" id="code_client10"  /></td>
        <td><input name="data[10][libelle]" type="text" size="10" id="libelle10"  /></td>
        <td><input name="data[10][poste]" type="text" value="Article 475-1-CPP" size="30" /></td>
        <td><input name="data[10][ordre]" type="text" size="2" id="position10" onblur="checkdiv()" /></td>
        <td><input name="data[10][description]" type="text" value="Article 475-1 Du code de Proc&eacute;dure p&eacute;nale" size="40" /></td><td><select name="data[10][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[10][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>
        <tr>

        <td><input name="data[11][code_client]" type="text" size="5" id="code_client11"  /></td>
        <td><input name="data[11][libelle]" type="text" size="10" id="libelle11"  /></td>
        <td><input name="data[11][poste]" type="text" value="Frais d'ex&eacute;cution" size="30" /></td>
        <td><input name="data[11][ordre]" type="text" size="2" id="position11" onblur="checkdiv()" /></td>
        <td><input name="data[11][description]" type="text" value="Montant des frais d'ex&eacute;cution" size="40" /></td><td><select name="data[11][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[11][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>

        <tr>
                <td><input name="data[12][code_client]" type="text" size="5" id="code_client12"  /></td>
        <td><input name="data[12][libelle]" type="text" size="10" id="libelle12"  /></td>
        <td><input name="data[12][poste]" type="text" value="Contribution &agrave; l'aide juridiqu" size="30" /></td>
        <td><input name="data[12][ordre]" type="text" size="2" id="position12" onblur="checkdiv()" /></td>
        <td><input name="data[12][description]" type="text" value="Contribution à l'aide juridique" size="40" /></td><td><select name="data[12][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[12][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>
        <tr>

        <td><input name="data[13][code_client]" type="text" size="5" id="code_client13"  /></td>
        <td><input name="data[13][libelle]" type="text" size="10" id="libelle13"  /></td>
        <td><input name="data[13][poste]" type="text" value="Frais de greffe" size="30" /></td>
        <td><input name="data[13][ordre]" type="text" size="2" id="position13" onblur="checkdiv()" /></td>
        <td><input name="data[13][description]" type="text" value="Montant des frais de greffe" size="40" /></td><td><select name="data[13][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[13][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>
   </tbody>
</table>

但是当我尝试使函数工作时,它告诉我无法读取 null 的属性样式。如果将数字放入“ordre”列的输入中,我只想隐藏带有数字的橙色框。如果有人在另一个框中写了两倍相同的数字,只是为了显示警报。我真的输了,因为这个开始不起作用。

任何建议或帮助将不胜感激

这是jsfiddle。http://jsfiddle.net/uXcQh/

4

1 回答 1

0

如果您在 head 标签中包含 JavaScript,这可能是原因,因为调用函数时 DOM 未完全加载。

<html>
   <head>
       <script></script>
   </head>
   <body>
   </body>
</html>

我的建议是改为这样做。

<html>
   <head>
   </head>
   <body>
       All your html goes here.
       FINALLY.
       <script></script>
   </body>
</html>

这是对我有用的代码

<html>
<body>
<form action="#" method="post">
<table width='100%' id='boxa' align='center' ><thead><tr><th scope='col' width='3%'><strong>CODE CLIENT</strong></th><th scope='col' width='10%'><strong>TITRE</strong></th><th scope='col' width='15%'><strong>POSTE</strong></th><th scope='col' width='3%'><strong>ORDRE</strong></th><th scope='col' width='25%'><strong>DESCRIPTION</strong></th><th scope='col' width='10%'><strong>VU CLIENT</strong></th><th scope='col' width='10%'><strong>VU TIERS</strong></th></tr></thead><tbody>    <tr>

        <td>
        <input name="data[1][code_client]" type="text"  id="code_client1" size="5"  onkeyup="clientventilation()" /></td>
        <td><input name="data[1][libelle]" type="text" size="10" id="libelle1" onkeyup="titreventilation()"  /></td>
        <td><input name="data[1][poste]" type="text" value="Principal" size="30" /></td>
        <td><input name="data[1][ordre]" id="position1" type="text" size="2"  onblur="checkdiv()" /></td>
        <td><input name="data[1][description]" type="text" value="Montant de la dette" size="40" /></td><td><select name="data[1][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[1][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>
        <tr>

        <td><input name="data[2][code_client]" type="text" size="5" id="code_client2"  /></td>
        <td><input name="data[2][libelle]" type="text" size="10" id="libelle2"   /></td>
        <td><input name="data[2][poste]" type="text" value="Int&eacute;r&ecirc;ts" size="30" /></td>
        <td><input name="data[2][ordre]" type="text" size="2" id="position2" onblur="checkdiv()" /></td>
        <td><input name="data[2][description]" type="text" value="Int&eacute;r&ecirc;ts (sur soldes des factures d&ucirc;es)" size="40" /></td><td><select name="data[2][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[2][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>

        <tr>

        <td><input name="data[3][code_client]" type="text" size="5" id="code_client3"  /></td>
        <td><input name="data[3][libelle]" type="text" size="10" id="libelle3"  /></td>
        <td><input name="data[3][poste]" type="text" value="Clause p&eacute;nale" size="30" /></td>
        <td><input name="data[3][ordre]" type="text" size="2" id="position3" onblur="checkdiv()" /></td>
        <td><input name="data[3][description]" type="text" value="Clause p&eacute;nale contractuelle" size="40" /></td><td><select name="data[3][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[3][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>
        <tr>

        <td><input name="data[4][code_client]" type="text" size="5" id="code_client4"  /></td>
        <td><input name="data[4][libelle]" type="text" size="10" id="libelle4"  /></td>
        <td><input name="data[4][poste]" type="text" value="Dommages et Int&eacute;r&ecirc;ts" size="30" /></td>
        <td><input name="data[4][ordre]" type="text" size="2" id="position4" onblur="checkdiv()" /></td>
        <td><input name="data[4][description]" type="text" value="Montant des Dommages et Int&eacute;r&ecirc;ts" size="40" /></td><td><select name="data[4][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[4][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>
        <tr>

        <td><input name="data[5][code_client]" type="text" size="5" id="code_client5"  /></td>
        <td><input name="data[5][libelle]" type="text" size="10" id="libelle5"  /></td>
        <td><input name="data[5][poste]" type="text" value="Article 700 du CPC" size="30" /></td>
        <td><input name="data[5][ordre]" type="text" size="2" id="position5" onblur="checkdiv()" /></td>
        <td><input name="data[5][description]" type="text" value="Montant correspondant &agrave; la condamnation" size="40" /></td><td><select name="data[5][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[5][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>
        <tr>

        <td><input name="data[6][code_client]" type="text" size="5" id="code_client6"  /></td>
        <td><input name="data[6][libelle]" type="text" size="10" id="libelle6"  /></td>
        <td><input name="data[6][poste]" type="text" value="Frais AR" size="30" /></td>
        <td><input name="data[6][ordre]" type="text" size="2" id="position6" onblur="checkdiv()" /></td>
        <td><input name="data[6][description]" type="text" value="Montant des frais d'accus&eacute;s r&eacute;ception et de courriers" size="40" /></td><td><select name="data[6][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[6][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>
        <tr>

        <td><input name="data[7][code_client]" type="text" size="5" id="code_client7"  /></td>
        <td><input name="data[7][libelle]" type="text" size="10" id="libelle7"  /></td>
        <td><input name="data[7][poste]" type="text" value="Art. 441-6 CC" size="30" /></td>
        <td><input name="data[7][ordre]" type="text" size="2" id="position7" onblur="checkdiv()" /></td>
        <td><input name="data[7][description]" type="text" value="Article 441-6 du code du commerce" size="40" /></td><td><select name="data[7][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[7][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>
        <tr>

        <td><input name="data[8][code_client]" type="text" size="5" id="code_client8"  /></td>
        <td><input name="data[8][libelle]" type="text" size="10" id="libelle8"  /></td>
        <td><input name="data[8][poste]" type="text" value="Frais et Agios" size="30" /></td>
        <td><input name="data[8][ordre]" type="text" size="2" id="position8" onblur="checkdiv()" /></td>
        <td><input name="data[8][description]" type="text" value="Montant des frais &amp; agios bancaires" size="40" /></td><td><select name="data[8][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[8][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>
        <tr>

        <td><input name="data[9][code_client]" type="text" size="5" id="code_client9"  /></td>
        <td><input name="data[9][libelle]" type="text" size="10" id="libelle9"  /></td>
        <td><input name="data[9][poste]" type="text" value="D&eacute;pens" size="30" /></td>
        <td><input name="data[9][ordre]" type="text" size="2" id="position9" onblur="checkdiv()" /></td>
        <td><input name="data[9][description]" type="text" value="Total calcul&eacute;" size="40" /></td><td><select name="data[9][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[9][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>

        <tr>

        <td><input name="data[10][code_client]" type="text" size="5" id="code_client10"  /></td>
        <td><input name="data[10][libelle]" type="text" size="10" id="libelle10"  /></td>
        <td><input name="data[10][poste]" type="text" value="Article 475-1-CPP" size="30" /></td>
        <td><input name="data[10][ordre]" type="text" size="2" id="position10" onblur="checkdiv()" /></td>
        <td><input name="data[10][description]" type="text" value="Article 475-1 Du code de Proc&eacute;dure p&eacute;nale" size="40" /></td><td><select name="data[10][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[10][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>
        <tr>

        <td><input name="data[11][code_client]" type="text" size="5" id="code_client11"  /></td>
        <td><input name="data[11][libelle]" type="text" size="10" id="libelle11"  /></td>
        <td><input name="data[11][poste]" type="text" value="Frais d'ex&eacute;cution" size="30" /></td>
        <td><input name="data[11][ordre]" type="text" size="2" id="position11" onblur="checkdiv()" /></td>
        <td><input name="data[11][description]" type="text" value="Montant des frais d'ex&eacute;cution" size="40" /></td><td><select name="data[11][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[11][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>

        <tr>
                <td><input name="data[12][code_client]" type="text" size="5" id="code_client12"  /></td>
        <td><input name="data[12][libelle]" type="text" size="10" id="libelle12"  /></td>
        <td><input name="data[12][poste]" type="text" value="Contribution &agrave; l'aide juridiqu" size="30" /></td>
        <td><input name="data[12][ordre]" type="text" size="2" id="position12" onblur="checkdiv()" /></td>
        <td><input name="data[12][description]" type="text" value="Contribution à l'aide juridique" size="40" /></td><td><select name="data[12][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[12][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>
        <tr>

        <td><input name="data[13][code_client]" type="text" size="5" id="code_client13"  /></td>
        <td><input name="data[13][libelle]" type="text" size="10" id="libelle13"  /></td>
        <td><input name="data[13][poste]" type="text" value="Frais de greffe" size="30" /></td>
        <td><input name="data[13][ordre]" type="text" size="2" id="position13" onblur="checkdiv()" /></td>
        <td><input name="data[13][description]" type="text" value="Montant des frais de greffe" size="40" /></td><td><select name="data[13][vu_client]" ><option value="oui">oui</option><option value="non">non</option></select></td><td><select name="data[13][vu_tiers]" ><option value="oui">oui</option><option value="non">non</option></select></td>
        </tr>
   </tbody>
</table>
    <table width="100%" border="0" cellspacing="5" cellpadding="5">
  <tbody><tr>
    <th scope="col"><div id="a1" style="width: 35px; height: 35px; border: 5px solid rgb(255, 127, 80); text-align: center; visibility: visible; "><font color="coral" size="+3"><strong>1</strong></font></div></th>
    <th scope="col"><div id="a2" style="width: 35px; height: 35px; border: 5px solid rgb(255, 127, 80); text-align: center; visibility: visible; "><font color="coral" size="+3"><strong>2</strong></font></div></th>
    <th scope="col"><div id="a3" style="width: 35px; height: 35px; border: 5px solid rgb(255, 127, 80); text-align: center; visibility: visible; "><font color="coral" size="+3"><strong>3</strong></font></div></th>
    <th scope="col"><div id="a4" style="width: 35px; height: 35px; border: 5px solid rgb(255, 127, 80); text-align: center; visibility: visible; "><font color="coral" size="+3"><strong>4</strong></font></div></th>
    <th scope="col"><div id="a5" style="width: 35px; height: 35px; border: 5px solid rgb(255, 127, 80); text-align: center; visibility: visible; "><font color="coral" size="+3"><strong>5</strong></font></div></th>
    <th scope="col"><div id="a6" style="width: 35px; height: 35px; border: 5px solid rgb(255, 127, 80); text-align: center; visibility: visible; "><font color="coral" size="+3"><strong>6</strong></font></div></th>
    <th scope="col"><div id="a7" style="width: 35px; height: 35px; border: 5px solid rgb(255, 127, 80); text-align: center; visibility: visible; "><font color="coral" size="+3"><strong>7</strong></font></div></th>
    <th scope="col"><div id="a8" style="width: 35px; height: 35px; border: 5px solid rgb(255, 127, 80); text-align: center; visibility: visible; "><font color="coral" size="+3"><strong>8</strong></font></div></th>
    <th scope="col"><div id="a9" style="width: 35px; height: 35px; border: 5px solid rgb(255, 127, 80); text-align: center; visibility: visible; "><font color="coral" size="+3"><strong>9</strong></font></div></th>
    <th scope="col"><div id="a10" style="width: 35px; height: 35px; border: 5px solid rgb(255, 127, 80); text-align: center; visibility: visible; "><font color="coral" size="+3"><strong>10</strong></font></div></th>
    <th scope="col"><div id="a11" style="width: 35px; height: 35px; border: 5px solid rgb(255, 127, 80); text-align: center; visibility: visible; "><font color="coral" size="+3"><strong>11</strong></font></div></th>
    <th scope="col"><div id="a12" style="width: 35px; height: 35px; border: 5px solid rgb(255, 127, 80); text-align: center; visibility: visible; "><font color="coral" size="+3"><strong>12</strong></font></div></th>
    <th scope="col"><div id="a13" style="width: 35px; height: 35px; border: 5px solid rgb(255, 127, 80); text-align: center; visibility: hidden; "><font color="coral" size="+3"><strong>13</strong></font></div></th>
  </tr>
</tbody></table>
?
<script type="text/javascript">
function checkdiv()
{
    var position1= document.getElementById("position1").value;
    if(position1== 1 )
    {
    alert(document.getElementById("a1"));
        document.getElementById("a1").style.visibility = "hidden"                        
    }
    else
    {
     document.getElementById("a1").style.visibility= "visible"                        
    }
    if(position1=="2")
    {
     document.getElementById("a2").style.visibility = "hidden"                        
    }
    if(position1!="2")
    {
     document.getElementById("a2").style.visibility= "visible"                        
    }
    if(position1=="3")
    {
     document.getElementById("a3").style.visibility = "hidden"                        
    }
    if(position1!="3")
    {
     document.getElementById("a3").style.visibility= "visible"                        
    }
     if(position1=="4")
    {
     document.getElementById("a4").style.visibility = "hidden"                        
    }
    if(position1!="4")
    {
     document.getElementById("a4").style.visibility= "visible"                        
    }  
     if(position1=="5")
    {
     document.getElementById("a5").style.visibility = "hidden"                        
    }
    if(position1!="5")
    {
     document.getElementById("a5").style.visibility= "visible"                        
    }
    if(position1=="6")
    {
     document.getElementById("a6").style.visibility = "hidden"                        
    }
    if(position1!="6")
    {
     document.getElementById("a6").style.visibility= "visible"                        
    }
     if(position1=="7")
    {
     document.getElementById("a7").style.visibility = "hidden"                        
    }
    if(position1!="7")
    {
     document.getElementById("a7").style.visibility= "visible"                        
    }
     if(position1=="8")
    {
     document.getElementById("a8").style.visibility = "hidden"                        
    }
    if(position1!="8")
    {
     document.getElementById("a8").style.visibility= "visible"                        
    }          
    if(position1=="9")
    {
     document.getElementById("a9").style.visibility = "hidden"                        
    }
    if(position1!="9")
    {
     document.getElementById("a9").style.visibility= "visible"                        
    }
     if(position1=="10")
    {
     document.getElementById("a10").style.visibility = "hidden"                        
    }
    if(position1!="10")
    {
     document.getElementById("a10").style.visibility= "visible"                        
    }          
    if(position1=="11")
    {
     document.getElementById("a11").style.visibility = "hidden"                        
    }
    if(position1!="11")
    {
     document.getElementById("a11").style.visibility= "visible"                        
    }   
    if(position1=="12")
    {
     document.getElementById("a12").style.visibility = "hidden"                        
    }
    if(position1!="12")
    {
     document.getElementById("a12").style.visibility= "visible"                        
    }
}  
  </script>

  </body>
  </html>
于 2012-10-05T07:34:00.837 回答