如何根据数据库行数在弹出窗口中动态创建表或div [英] How do I create an table or div dynamically on popup window based on database rows count

查看:99
本文介绍了如何根据数据库行数在弹出窗口中动态创建表或div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Guys,



我必须根据数据库行数创建一个表或div。

假设有20行在数据库上。所以应该动态创建2个div或td。

如果数据库中有25行可用,则应动态创建3个div或td。

和表行应显示在div或td。



实际上我正在使用window.open方法打开一个弹出窗口,它有链接按钮。点击链接按钮要么我必须打开另一个弹出窗口并根据数据库表行创建一个表或分区标记,或者在同一个弹出窗口中我必须创建div或表本身并基于否。 div的窗口大小应该调整大小。



我尝试过:



我想知道如何在基于数据库表行数的弹出窗口中执行此操作。

Hello Guys,

I have to create a table or div based on database rows count.
Suppose, 20 rows are there on database. So 2 div or td should be created dynamically.
If 25 rows are available on database then 3 div or td should be created dynamically.
and table rows should be shown on div or td.

Actually i am opening a popup window using window.open method and it has link button. On click of link button either i have to open another popup window and create a table or division tag based on database table rows or on the same popup window i have to create the div or table itself and based on no. of divs window size should be resized.

What I have tried:

I am wondering how to do this on popup window based on database table rows count.

推荐答案

对于动态创建表,可以使用以下方法:



- 在弹出窗口中创建一个标签,即lblData

- 点击你的按钮点击下面的代码:

For create table dynamically use can use following method:

- Create one label in your popup window i.e. lblData
- On your button click write following code:
var sTableData = '';
	var iRow = 0;
	sTableData = '<table>';
	for(iRow=0;iRow<=tablerowcount;iRow++)
	{
		sTableData = sTableData + '<tr><td>specify data you want show</td</tr>';
	}
	sTableData = sTableData + '</table>;

	document.getElementById('lblData').innerHTML = sTableData;



希望它会有所帮助。


Hope it will be helpful.


这篇关于如何根据数据库行数在弹出窗口中动态创建表或div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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