Click here to Skip to main content
15,906,569 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
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.
Posted
Updated 14-Mar-11 23:18pm
v4

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.
 
Share this answer
 
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!
 
Share this answer
 
v2
1. I tried on my computer, the below code in working fine.
JavaScript
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);
}
 
Share this answer
 
v2
Comments
Henry Minute 15-Mar-11 8:21am    
Please surround code snippets with <pre> tags. It makes them so much easier to read.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900