document.getElementById('')。display =阻止不起作用

时间:2019-01-31 01:17:02

标签: javascript

在以下文档中,当有人单击收音机(在表中)时,将调用StOptnClkd函数。除了最重要的事情,它完成了所有事情。有两个元素需要从显示切换为不显示,即-AmxDisc和stOptnsTbl。这些元素根据单选按钮和复选框上的选择显示。请帮助我。我是一个尝试学习编码的新手

我已附上以下代码

        <script type="text/javascript">
    function StOptnClkd(clicked_id)
    {
        //alert(clicked_id)
        var strvid = clicked_id;
        var StVal = document.getElementById(strvid).value;
        document.getElementById("STtypCptrd").checked="Checked";
        document.getElementById("cntctpe").innerHTML=StVal;
        document.getElementById('Autonote').value = document.getElementById('Autonote').value+"Spke to: " + StVal; + ", ";
        document.getElementById("AmxDisc").display="Block" // this doesnt show
        document.getElementById("stOptnsTbl").display="None"  // this doesnt get hidden
    }
    </script>


<table  id="stOptnsTbl" border cellspacing="50px" style="text-align: center; border: 1px solid black; border-collapse: collapse;float: left; display: none">
    <tr>        <!--All Party Options-->
        <td width="110px" id ="CMOptn" class="stOptions">
    <label class="container1" style="float:Left"><Strong>  CM</Strong>
     <input id= "optstCM" type="radio" value ="CM" Name="stPrtysel" onclick="StOptnClkd(this.id)">
     <span class="checkmark1"></span>
    </label>    
    </td>
    <td width="110px" id ="UTPOptn" class="stOptions">
        <label id="lblUPT" class="container1" style="float:Left"><Strong> UTP</Strong>
     <input id= "optUTP" type="radio" value ="UTP" Name="stPrtysel" checked="checked" onclick="StOptnClkd(this.id)" >
     <span class="checkmark1"></span>
    </label>    
    </td>
    <td width="110px" id ="SPOptn" class="stOptions">
        <label id="lblSP" class="container1" style="float:Left;"><Strong> SP    </Strong>
     <input id= "optSP" type="radio" value ="SP" Name="stPrtysel" onclick="StOptnClkd(this.id)" >
     <span class="checkmark1"></span>
    </label>
    </td>
    <td width="110px"  id ="SUPOptn" class="stOptions">
        <label id="lblSUP" class="container1" style="float:Left;"><Strong> SUP    </Strong>
     <input id= "optSUP" type="radio" value ="SUP" Name="stPrtysel"onclick="StOptnClkd(this.id)" >
     <span class="checkmark1"></span>
    </label>
    </td>
    <td width="110px" id ="ATPOptn" class="stOptions">
        <label id="lblATP" class="container1" style="float:Left;"><Strong> ATP    </Strong>
     <input id= "optATP" type="radio" value ="ATP" Name="stPrtysel"onclick="StOptnClkd(this.id)" >
     <span class="checkmark1"></span>
    </label>
    </td>
    <td width="110px" id ="ATTOptn" class="stOptions">
        <label id="lblATT" class="container1" style="float:Left;"><Strong> ATT   </Strong>
     <input id= "optATT" type="radio" value ="AM" Name="stPrtysel" onclick="StOptnClkd(this.id)">
     <span class="checkmark1"></span>
    </label>
    </td>
    <td width="110px" id ="AMOptn" class="stOptions">
        <label id="lblAM" class="container1" style="float:Left;"><Strong> AM    </Strong>
     <input id= "optAM" type="radio" value ="AM" Name="stPrtysel" onclick="StOptnClkd(this.id)" >
     <span class="checkmark1"></span>
    </label>
    </td>








</span>
</span>
</tr>
</table>
<span width="100%" id="AmxDisc" style="display:none;">
     has referred your  account to  for resolution.

编辑:就在这里,很遗憾在这里张贴所有代码,如果你们需要整个代码告诉我,我可以邮寄。或找到一种方法放置在这里

Edit2:我做了style.display的更改。它仍然没有做到这一点。在控制台中,它显示错误,指出该行出现意外的标识符

1 个答案:

答案 0 :(得分:0)

document.getElementById(“ AmxDisc”)。style.display =“ block”