Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

moving table columns

Posted on 2008-10-06
3
Medium Priority
?
529 Views
Last Modified: 2009-12-21
a table with prev and next to move the columns.
when i do prev and next i want the first columns (blue) not to move and remain visible all the time.
i dont want to split it into 2 tables.
pl help.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title></title>
<style type="text/css">/* <![CDATA[ */
 
#theTable {
  width: 1700px;
}
#theTable td {
  width: 170px;
}
 
/* ]]> */</style>
<script type="text/javascript">/* <![CDATA[ */
if((typeof($id)=='undefined')&&document.getElementById){
  window.$id=function(s){return document.getElementById(s)}
}
 
var horzTableScroll = {
  colWidth: 170,
  init:function(){
    if(!document.createTextNode) return;
    var controls = $id('controls');
    var link = document.createElement('a');
    link.href="#";
    link.appendChild(document.createTextNode('Prev'));
    var link2=link.cloneNode(false);
    link=controls.appendChild(link);
    controls.appendChild(document.createTextNode(' '));
    link.onclick=function(){return horzTableScroll.scroll(-1)};
    link2.appendChild(document.createTextNode('Next'));
    link2=controls.appendChild(link2);
    link2.onclick=function(){return horzTableScroll.scroll(1)};
    var scroller = $id('scroller');
    scroller.style.width='850px';
    scroller.style.overflow='hidden';
  },
  scroll:function(dir){
    var par = $id('scroller');
    var newNum = par.scrollLeft + dir*horzTableScroll.colWidth;
    if((newNum>=0) && (newNum <= $id('theTable').offsetWidth-par.clientWidth))
      par.scrollLeft = newNum;
    return false;
  }
};
 
window.onload = function(){
  horzTableScroll.init();
 
}
/* ]]> */</script>
</head>
<body>
 
<div id="controls"></div><br/>
<div id="scroller">
<table id="theTable" cellspacing="0" cellpadding="2" border="1">
  <tr>
    <td bgcolor="blue">1</td>
    <td>2</td>
    <td>3</td>
    <td>4</td>
    <td>5</td>
    <td>6</td>
    <td>7</td>
    <td>8</td>
    <td>9</td>
    <td>10</td>
  </tr>
  <tr>
    <td bgcolor="blue">2</td>
    <td>fsdfsd</td>
    <td>sfdsf</td>
    <td>ffsf</td>
    <td>fsfsd</td>
    <td>11</td>
    <td>12</td>
    <td>13</td>
    <td>14</td>
    <td>15</td>
  </tr>
  <tr>
    <td bgcolor="blue">3</td>
    <td>fsdfsd</td>
    <td>sfdsf</td>
    <td>ffsf</td>
    <td>fsfsd</td>
    <td>21</td>
    <td>22</td>
    <td>23</td>
    <td>24</td>
    <td>25</td>
  </tr>
  <tr>
    <td bgcolor="blue">4</td>
    <td>fsdfsd</td>
    <td>sfdsf</td>
    <td>ffsf</td>
    <td>fsfsd</td>
    <td>31</td>
    <td>32</td>
    <td>33</td>
    <td>34</td>
    <td>35</td>
  </tr>
  <tr>
    <td bgcolor="blue">5</td>
    <td colspan="2">sfdsf</td>
    <td>ffsf</td>
    <td>fsfsd</td>
    <td>41</td>
    <td>42</td>
    <td>43</td>
    <td>44</td>
    <td>45</td>
  </tr>
  <tr>
    <td bgcolor="blue">6</td>
    <td colspan="2">fsdfsd</td>
    <td>sfdsf</td>
    <td>ffsf</td>
    <td colspan="3">fsfsd</td>  
    <td>54</td>
    <td>55</td>
  </tr>
</table>
</div>
 
 
</body>
</html>

Open in new window

0
Comment
Question by:vidhubala
[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
3 Comments
 
LVL 44

Accepted Solution

by:
scrathcyboy earned 2000 total points
ID: 22656317
Have you checked to see if these javascript operators even work in browsers other than IE?  I think most of the calls are IE specific, and won't work in other browsers.  But try them.
0
 

Author Comment

by:vidhubala
ID: 22656321
answer not specific to my question. thanks.
0
 

Author Comment

by:vidhubala
ID: 22673310
hi scrath,

so do u know any other way to do it? FYI it works in ie and all firefox versions..
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

722 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