单击按钮时使用脚本(如何添加五个复选框,五个名称和五个图像)的ASP.NET [英] ASP.NET using script (how to add five check boxes five names and five images) when button is clicked

查看:70
本文介绍了单击按钮时使用脚本(如何添加五个复选框,五个名称和五个图像)的ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的aspx页面中有一个按钮.
单击该按钮时,我必须一个接一个地获得5个复选框和5个名称和5张图像...我该怎么做.

I have one button in my aspx page.
When click that button I have to get 5 check boxes and five names and five images one by one... how can I do this.

推荐答案

希望您的复选框,图片等是静态的.将它们全部创建在具有ID myTable 的html表中.编写一个JavaScript函数 showTable()使该表可见/不可见.将该功能链接到按钮的onclick事件.
Hope your check boxes, images, etc are static. create them all in a html table with some ID myTable. Write a javascript function showTable() to make that table visible / invisible. link that function to that onclick event of your button.


步骤:
1.在按钮单击事件中,创建一个表和所需的表列(我想3-复选框,名称和图像)
2.创建一个以5作为限制的for循环
3.创建一个表格行
4.创建一个复选框,并将其添加到该行的第一列
5.创建一个标签并添加到该行的第二列
6.创建一个图像并添加到该行的第三列
7.将行添加到表中
8.循环结束后,将表添加到ASPX中的面板/占位符.

完毕!立即尝试!
Steps:
1. In button click event, Create a table and needed table columns (3 I guess - Checkbox, Name & Image )
2. Create a for loop with 5 as limit
3. Create a Table row
4. Create a checkbox and add to first column of the row
5. Create a label and add to second column of the row
6. Create an image and add to third column of the row
7. Add the row to the table
8. Once loop finishes, add table to the panel/placeholder in the ASPX.

Done! Try now!


1.我在计算机上尝试了以下代码,但工作正常.
1. I tried on my computer, the below code in working fine.
function CreateCheckBox()
{
//Create table
    var tbl = document.createElement('table');
    tbl.border = "1";

    //create a row
    var row = document.createElement('tr');
    row.className = 'gridrow';

    //create td element
    td = document.createElement('td');
    td.className = 'gridcell';
    td.style.fontWeight = 'normal';
    td.rowSpan = 1;
    td.style.width = '80px';

    //create checkbox in that td element
    var chkbox = document.createElement('input');
    chkbox.type = "checkbox";
    chkbox.id = "chk" ;
    chkbox.name = "chk" ;

    //add checkbox to td element
    td.appendChild(chkbox);

    td1 = document.createElement('td');
    var lbl = document.createElement('input');
    lbl.type = "text";
    lbl.id = "lbl1";
    lbl.name = "lblName";
    lbl.value = "vivek";
    lbl.border = "0";
    td1.appendChild(lbl);
    //add td element to row
    row.appendChild(td);
    row.appendChild(td1);

    tbl.appendChild(row);
    
    form1.appendChild(tbl);
}


这篇关于单击按钮时使用脚本(如何添加五个复选框,五个名称和五个图像)的ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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