Solved

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

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
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 …
Suggested Courses

617 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