在表中启用和禁用td [英] Enable and Disable td in table

查看:255
本文介绍了在表中启用和禁用td的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

onchange ='onFocusReportingOptions()

;'>
< option value =选择>选择< / option>
< option value =Y>是< / option>
< option value =N>否< / option>
< / select>
< / td>

选择Yes或No后,下面的TD应显示或不显示用户。

 < td id =first_td>< select class =dropDownListsname = reportingOption id =reportFlagtabindex =10style =WIDTH:160pxonchange ='callonChange();'> 
< option value =选择>选择< / option>
< option value =MyTell>通过工具报告< / option>
< option value =手动>手动报告< / option>
< / select>
< / td>
< td id =second_td>< select class =dropDownListsname = acctFlag id =acctFlagtabindex =10style =WIDTH:160pxonchange ='callonChange();' >
< option value =选择>选择< / option>
< option value =Y>是< / option>
< option value =N>否< / option>
< / select>
< / td>

我的问题控制显示td的方法是什么?
我可以做的一种方式是使用DIV标签,但是如果我们使用Div标签,我知道我们需要在td中使用表格,在这种情况下,对齐会是一个问题。


可以有任何其他建议吗?

解决方案

给TD一个ID。然后使用Javascript隐藏具有相关ID的元素(通过CSS显示属性)。

 < td id =first_td >内容< / TD> 
< td id =second_id>< content< / td>

var elem = document.getElementById(first_td);
elem.style.display =none;

隐藏或显示TD的逻辑可以封装在选择下拉列表的事件处理程序中,向下。


<td><select class="dropDownLists" name=reportFlag id="reportFlag" tabindex="10" style="WIDTH: 160px" onchange='onFocusReportingOptions();'> 
        <option value="Select">Select</option>
        <option value="Y">Yes</option>
        <option value="N">No</option>
        </select>    
</td>

After I select the option Yes or No, below TD's should be shown or not to the user.

<td id="first_td"><select class="dropDownLists" name=reportingOption id="reportFlag" tabindex="10" style="WIDTH: 160px" onchange='callonChange();'> 
        <option value="Select">Select</option>
        <option value="MyTell">Report via tool</option>
        <option value="Manual">Report via manually</option>
        </select>
</td>
<td id="second_td"><select class="dropDownLists" name=acctFlag id="acctFlag" tabindex="10" style="WIDTH: 160px" onchange='callonChange();'> 
        <option value="Select">Select</option>
        <option value="Y">Yes</option>
        <option value="N">No</option>
        </select>
</td>

My questions what are the ways to control the display of the td? one way I can do is with the DIV tags but if we use Div tag i learnt that we need to use table inside the td, in that case then the alignment will be a problem

can any one suggest any other way to get this implemented?

解决方案

Give the TDs an ID. Then use Javascript to hide the element with the relevant ID (via the CSS display attribute).

<td id="first_td">content</td>
<td id="second_id"><content</td>

var elem = document.getElementById("first_td");
elem.style.display = "none";

The logic for which TD is hidden or shown can be encapsulated in an event handler for the select drop-down.

这篇关于在表中启用和禁用td的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆