Solved

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

Posted on 2007-03-19
2
524 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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 embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now