Solved

Divider that can move

Posted on 2004-09-15
4
230 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

930 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

12 Experts available now in Live!

Get 1:1 Help Now