Click here to Skip to main content
15,942,710 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
XML
<
script type="text/javascript">
        function Addrow() {
            var table = document.getElementById("successFailure");
            var row = table.insertRow(2);
            var cell1 = row.insertCell();
            cell1.innerHTML = "Format and Store Type";
        }
    </script>



--From the list that i am getting from the controller, i am displaying the data in an html table.

for example

column1    column2    column3     column4
 uk           23        23           23
 x            11        11           45
 y            22        63           22
 z            11        35           46 

--but i needed an row at the second position without border

column1    column2    column3     column4
 uk           23        23           23
 format
 x            11        11           45
 y            22        63           22
 z            11        35           46 

--I did it on onload function. But i want to remove the border of the cell. As "format" is bordered in the first cell. I want to remove the border in the cell. So a blank row is needed 
with text as "format".

Kindly help.
Posted

1 solution

By default, there are no any borders. If you see some borders, it means you added them somewhere.

The best to control borders is using CSS:
http://www.w3schools.com/css/css_border.asp[^],
http://www.w3schools.com/cssref/pr_border.asp[^].

Actually, you should not use any HTML tags related to styles except class, which also should be used sparsely. You can also define CSS classes on the fly in your scripts.

If you need to change the CSS classes of some element on the fly, the best way to do it is using jQuery: http://api.jquery.com/category/css[^].

If you need to learn jQuery (highly recommended), please see:
http://en.wikipedia.org/wiki/JQuery[^],
http://jquery.com[^],
http://learn.jquery.com[^],
http://learn.jquery.com/using-jquery-core[^],
http://learn.jquery.com/about-jquery/how-jquery-works[^] (start from here).

—SA
 
Share this answer
 
Comments
anurag19289 23-Feb-14 14:09pm    
var table = document.getElementById("successFailure");
var row = table.insertRow(2);
var cell1 = row.insertCell();
cell1.innerHTML = "Format and Store Type";

--in this line var cell1 = row.insertCell(); Here it inserts a cell. If i pass parameter as 1 or nothing then it creates a cell with border.

--Meanwhile let me check the links that you provided.
Sergey Alexandrovich Kryukov 23-Feb-14 14:37pm    
There is nothing directly related to styles in this code fragment. You just need to take care of styles of the elements "table", "tr" and "td" (table, row and cell). My answer merely explains how.
—SA
Maciej Los 23-Feb-14 17:16pm    
Exactly!
Maciej Los 23-Feb-14 17:16pm    
+5!
Sergey Alexandrovich Kryukov 23-Feb-14 18:14pm    
Thank you, Maciej.
—SA

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