Solved

Divider that can move

Posted on 2004-09-15
4
229 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
Comment Utility
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
Comment Utility
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
Comment Utility
use my original code  :-)  (whatever I posted a few days ago)
0
 
LVL 9

Accepted Solution

by:
cwolves earned 500 total points
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

772 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