如何手动控制TABLE需要显示的行数和列数

清风止雨 2017-09-27 03:37:46
现在做了一个table是24行 12列,但是每次录入数据的时候未必需要的行列不同,为了防错,只显示需要填入数据的表格,其他的隐藏,通过什么来完成?
...全文
811 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
clark_kidd 2017-09-29
  • 打赏
  • 举报
回复
引用 4 楼 u010361914 的回复:
[quote=引用 3 楼 clark_kidd 的回复:] [quote=引用 2楼我是你的主体 的回复:][quote=引用 1 楼 clark_kidd 的回复:]

<table id="t">
	<tr>
		<td>line No.</td>
		<td>title1</td>
		<td>title2</td>
		<td>title3</td>
	</tr>
	<tr>
		<td>1</td>
		<td>a</td>
		<td>b</td>
		<td>c</td>
	</tr>
	<tr>
		<td>2</td>
		<td>d</td>
		<td>e</td>
		<td>f</td>
	</tr>
</table>
<button onclick="f1()">隐藏第1行</button>
<button onclick="f2()">隐藏第2行 第3列</button>
<button onclick="f3()">看table一共有几个cell</button>
<button onclick="f4()">隐藏第11个cell(2行 3列)</button>
<script>
var table = document.getElementById("t");
function f1(){
	table.rows[1].style.display = "none";
}
function f2(){
	table.rows[2].cells[2].style.display = "none";
}
function f3(){
	alert(table.cells.length + ",包含了title的所有cell");
}
function f4(){
	table.cells[10].style.display = "none";
}
</script>
能够在表格的页面设置2个下拉框 一个定行数 一个定列数 让录入数据的人员自己选定表格大小么[/quote]能。不过下拉框够吗?一个设置显示n行,另一个m列?需求中不存在需要显示第3,5,7列的情况?[/quote]是的 只需要设定行和列,2个下拉框就够了,最大也就24行 12列[/quote] 那当然可以,在下拉框的onchange事件里用for循环逐行逐列隐藏就行了
清风止雨 2017-09-29
  • 打赏
  • 举报
回复
引用 3 楼 clark_kidd 的回复:
[quote=引用 2楼我是你的主体 的回复:][quote=引用 1 楼 clark_kidd 的回复:]

<table id="t">
	<tr>
		<td>line No.</td>
		<td>title1</td>
		<td>title2</td>
		<td>title3</td>
	</tr>
	<tr>
		<td>1</td>
		<td>a</td>
		<td>b</td>
		<td>c</td>
	</tr>
	<tr>
		<td>2</td>
		<td>d</td>
		<td>e</td>
		<td>f</td>
	</tr>
</table>
<button onclick="f1()">隐藏第1行</button>
<button onclick="f2()">隐藏第2行 第3列</button>
<button onclick="f3()">看table一共有几个cell</button>
<button onclick="f4()">隐藏第11个cell(2行 3列)</button>
<script>
var table = document.getElementById("t");
function f1(){
	table.rows[1].style.display = "none";
}
function f2(){
	table.rows[2].cells[2].style.display = "none";
}
function f3(){
	alert(table.cells.length + ",包含了title的所有cell");
}
function f4(){
	table.cells[10].style.display = "none";
}
</script>
能够在表格的页面设置2个下拉框 一个定行数 一个定列数 让录入数据的人员自己选定表格大小么[/quote]能。不过下拉框够吗?一个设置显示n行,另一个m列?需求中不存在需要显示第3,5,7列的情况?[/quote]是的 只需要设定行和列,2个下拉框就够了,最大也就24行 12列
清风止雨 2017-09-28
  • 打赏
  • 举报
回复
引用 1 楼 clark_kidd 的回复:

<table id="t">
	<tr>
		<td>line No.</td>
		<td>title1</td>
		<td>title2</td>
		<td>title3</td>
	</tr>
	<tr>
		<td>1</td>
		<td>a</td>
		<td>b</td>
		<td>c</td>
	</tr>
	<tr>
		<td>2</td>
		<td>d</td>
		<td>e</td>
		<td>f</td>
	</tr>
</table>
<button onclick="f1()">隐藏第1行</button>
<button onclick="f2()">隐藏第2行 第3列</button>
<button onclick="f3()">看table一共有几个cell</button>
<button onclick="f4()">隐藏第11个cell(2行 3列)</button>
<script>
var table = document.getElementById("t");
function f1(){
	table.rows[1].style.display = "none";
}
function f2(){
	table.rows[2].cells[2].style.display = "none";
}
function f3(){
	alert(table.cells.length + ",包含了title的所有cell");
}
function f4(){
	table.cells[10].style.display = "none";
}
</script>
能够在表格的页面设置2个下拉框 一个定行数 一个定列数 让录入数据的人员自己选定表格大小么
clark_kidd 2017-09-28
  • 打赏
  • 举报
回复
引用 2楼我是你的主体 的回复:
[quote=引用 1 楼 clark_kidd 的回复:]

<table id="t">
	<tr>
		<td>line No.</td>
		<td>title1</td>
		<td>title2</td>
		<td>title3</td>
	</tr>
	<tr>
		<td>1</td>
		<td>a</td>
		<td>b</td>
		<td>c</td>
	</tr>
	<tr>
		<td>2</td>
		<td>d</td>
		<td>e</td>
		<td>f</td>
	</tr>
</table>
<button onclick="f1()">隐藏第1行</button>
<button onclick="f2()">隐藏第2行 第3列</button>
<button onclick="f3()">看table一共有几个cell</button>
<button onclick="f4()">隐藏第11个cell(2行 3列)</button>
<script>
var table = document.getElementById("t");
function f1(){
	table.rows[1].style.display = "none";
}
function f2(){
	table.rows[2].cells[2].style.display = "none";
}
function f3(){
	alert(table.cells.length + ",包含了title的所有cell");
}
function f4(){
	table.cells[10].style.display = "none";
}
</script>
能够在表格的页面设置2个下拉框 一个定行数 一个定列数 让录入数据的人员自己选定表格大小么[/quote]能。不过下拉框够吗?一个设置显示n行,另一个m列?需求中不存在需要显示第3,5,7列的情况?
clark_kidd 2017-09-27
  • 打赏
  • 举报
回复

<table id="t">
	<tr>
		<td>line No.</td>
		<td>title1</td>
		<td>title2</td>
		<td>title3</td>
	</tr>
	<tr>
		<td>1</td>
		<td>a</td>
		<td>b</td>
		<td>c</td>
	</tr>
	<tr>
		<td>2</td>
		<td>d</td>
		<td>e</td>
		<td>f</td>
	</tr>
</table>
<button onclick="f1()">隐藏第1行</button>
<button onclick="f2()">隐藏第2行 第3列</button>
<button onclick="f3()">看table一共有几个cell</button>
<button onclick="f4()">隐藏第11个cell(2行 3列)</button>
<script>
var table = document.getElementById("t");
function f1(){
	table.rows[1].style.display = "none";
}
function f2(){
	table.rows[2].cells[2].style.display = "none";
}
function f3(){
	alert(table.cells.length + ",包含了title的所有cell");
}
function f4(){
	table.cells[10].style.display = "none";
}
</script>

87,990

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧