Solved

Divider that can move

Posted on 2004-09-15
4
231 Views
Last Modified: 2006-11-17
Hi Experts,

Here is the code of my divider:

<html>
<head>
</head>
<body>
<form>
<input type=text name="__SPLITTERLOC">
<table style="width:300px;border:1px solid #000000;position:relative;" cellspacing="0" cellpadding="0" id="tbl">
     <tr >
          <td id="f1">test data</td>
      <td width="6" rowspan="11" height="100%" id="mid"
       style="cursor:w-resize;" bgColor="black"
       onmousedown="bResize=true;">&nbsp;</td>
          <td id="f2">more test data</td>
     </tr>
     <tr>
          <td id="f1">test data</td>
          <td id="f2">more test data</td>
     </tr>
     <tr>
          <td id="f1">test data</td>
          <td id="f2">more test data</td>
     </tr>
</table>
</form>
<script language='javascript'>
bResize = false;
c1      = document.getElementById('f1');
c2      = document.getElementById('f2');
ttbl    = document.getElementById('tbl');
tmid    = document.getElementById('mid');
function resize(e){
     if(!bResize) return false;
     c1.className=c2.className='highlighted';
     if(!e) e=event;
     var w=e.clientX-ttbl.offsetLeft-5;
       if(w<ttbl.offsetWidth*.2) w=tbl.offsetWidth*.2;
            c1.style.width=w;
     return false;
}
function up(){
     bResize = false;
     document.forms[0].__SPLITTERLOC.value =c1.style.width;
     c1.className=c2.className='normal';
}
document.onmousemove = resize;
document.onmouseup   = up;
</script>
</body>
</html>

I want my table to be resized when the user moves the divider on the right side (table grows when divider moves on the right, reduces when divider moves on the left, but I want the control inside cell right to be always visible).

Thanks in advance for your answers.
0
Comment
Question by:noulouk
  • 3
4 Comments
 
LVL 9

Expert Comment

by:cwolves
ID: 12065239
take the "width:300px" out of the table style and put "width:150px" (or whatever you want) in the first two td cells.
0
 
LVL 9

Author Comment

by:noulouk
ID: 12065680
OK, but the divider stop moving to the right side when "table width = 100%".
This was my real trouble: I want my user to be able to move the divider to the right as far as he wants instead of being limited to the window.
0
 
LVL 9

Expert Comment

by:cwolves
ID: 12065695
use my original code  :-)  (whatever I posted a few days ago)
0
 
LVL 9

Accepted Solution

by:
cwolves earned 500 total points
ID: 12065822
or make this the first <tr>


     <tr >
          <td><img id="f1" src="http://test.webstorepackage.com/common_images/spacer.gif" height="0" width="1"></td>
      <td width="6" rowspan="11" height="100%" id="mid"
       style="cursor:w-resize;" bgColor="black"
       onmousedown="bResize=true;">&nbsp;</td>
          <td id="f2"><img src="http://test.webstorepackage.com/common_images/spacer.gif" height="0" width="1"></td>
     </tr>
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

831 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