?
Solved

How to set a different table border width on top than sides?

Posted on 2010-09-07
4
Medium Priority
?
268 Views
Last Modified: 2012-05-10
I have a page that creates a nested table via javascript when a user clicks a button on the page.


the table looks like this:

<table border="1">
   <tr>
      <td>text1</td>
      <td>text2</td>
   </tr>
</table>


if a user clicks a button on the page it looks like the code attached.

the top and bottom borders get doubled when the nested tables are added w/ the javascript. is there a way to set the properties on the nested table not to have a border on the top or bottom but still to have innder borders between the cells and rows?



<table border ="1">
   <tr>
      <td>text1</td>
      <td>text2</td>
   </tr>
   <div>
      <table border ="1">
         <tr>
            <td>text1</td>
            <td>text2</td>
         </tr>
      </table>
   </div>
</table>

Open in new window

0
Comment
Question by:ob1_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 15

Expert Comment

by:Insoftservice
ID: 33620168
hi
may i get the code thru which ur getting nested table.
You can set border =0 and after every click increment by 1 and give max no as 2.
so even if ur nested query increases to 7 it would be only 2.
Please note:
Its an algo and not actual code
0
 
LVL 5

Accepted Solution

by:
wmadrid1 earned 2000 total points
ID: 33620440
<table border ="1" rules="cols">
0
 
LVL 6

Author Comment

by:ob1_
ID: 33620717
wmadrid: the rules=cols option looks pretty good! if i could get it to apply in between the rows as well that would be perfect but its a good start.
insoft: i have included the javascript function. you can see the contents of newdiv.innerHTML that get written within the div that is created inside my existing table when the rows are added.
 

function addEvent() {
  var ni = document.getElementById('myDiv');
  var numi = document.getElementById('theValue');
  var num = (document.getElementById("theValue").value -1)+ 2;
  numi.value = num;
  var divIdName = "my"+num+"Div";
  var newdiv = document.createElement('div');
  newdiv.setAttribute("id",divIdName);
  newdiv.innerHTML = "<table width=\"100%\" border=\"1\" rules=\"cols\"><colgroup><col width=\"30%\"><col width=\"70%\"></colgroup><tr><td>Name:<a href=\"javascript:;\" onclick=\"removeElement(\'"+divIdName+"\')\" style=\"text-decoration:none; color: blue;\">&nbsp; &nbsp;(Remove)</a></td><td><input type=\"text\" name=\"client_name_"+num+"\" size=\"78\" style=\"background-color:white;border:0px solid white;\"></input></td></tr><tr><td>Email:</td><td><input type=\"text\" name=\"client_email_"+num+"\" size=\"78\" style=\"background-color:white;border:0px solid white;\"></input></td></tr></table>";
  ni.appendChild(newdiv);
}
 
function removeElement(divNum) {
  var d = document.getElementById('myDiv');
  var olddiv = document.getElementById(divNum);
  d.removeChild(olddiv);
}
</script>

Open in new window

0
 
LVL 13

Expert Comment

by:ansudhindra
ID: 33624620
Hi, you can try the below code..


<style type="text/css">
      .border{border:1px solid #000;}
      .bordertop{border-top:1px solid #000;}
      .borderbottom{border-bottom:1px solid #000;}
      .borderleft{border-left:1px solid #000;}
      .borderright{border-right:1px solid #000;}
    </style>
    <table border="0" cellpadding="0" cellspacing="0" >
   <tr>
      <td class="border">text1</td>
      <td class="bordertop borderright borderbottom">text2</td>
   </tr>
   <div>
      <table border ="0" cellpadding="0" cellspacing="0">
         <tr>
            <td class="borderleft borderbottom borderright">text1</td>
            <td class="borderright borderbottom">text2</td>
         </tr>
      </table>
   </div>
</table>

Open in new window

0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question