Solved

CSS with javascript code that draw a border for table's row.

Posted on 2007-03-19
2
526 Views
Last Modified: 2010-05-18
Hi, I need CSS with javascript code that draw a border for table's row(Please note row and not cell).
0
Comment
Question by:Abdu_Allah
2 Comments
 
LVL 15

Accepted Solution

by:
stanscott2 earned 500 total points
ID: 18751137
Say you have this table:

<table id="myTable">
     <tr>
          <td></td>
     </tr>
     <tr>
         <td></td>
     </tr>
</table>

And you want a border around the second row.  Use this:

function setBorder() {
     var rowToSet = document.getElementById("myTable").rows[1];
     rowToSet.style.border = '2px solid black';
}
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 18751384
Are you sure that works?! it does not work with me: here is my entire page:

<HTML>
<HEAD>
 <script type="text/javascript">
      function setborder(){
      var rowToSet = document.getElementById("myTable").rows[1];
     rowToSet.style.border = '2px solid black';
     }
</script>
</HEAD>
<BODY onload="myfunction">

<table id="myTable"  >
     <tr >
          <td>row 1</td>
     </tr>
     <tr>
         <td>row 2</td>
     </tr>
     <input type="button" onclick="setborder()" value="test" />
</table>
</BODY>
</HTML>


0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

773 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