Current location: Hot Scripts Forums » General Web Coding » JavaScript » Draggable Tables

Draggable Tables

Reply
  #1 (permalink)  
Old 08-02-06, 08:42 AM
Ares Ares is offline
Newbie Coder
 
Join Date: May 2006
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Draggable Tables

How can i make my tables draggable, cross-browser as well, thnx in advanced.

Page Code:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Template_003</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<STYLE type="text/css">
 <!--
 BODY { 
               background-repeat:repeat-x;
               background-position:top center;
               background-attachment:fixed }
 -->
</STYLE>
<body bgcolor="74513b" background="images/bg.jpg">
<table width="39%"  border="0" cellspacing="0" cellpadding="0" name="Content Box">
  <tr> 
    <td height="169"><table width="407"  border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td colspan="3"><img src="images/Template_003_01.png" width="404" height="11"></td>
        </tr>
        <tr> 
          <td width="43"><img src="images/Template_003_02.png" width="43" height="15"></td>
          <td width="345" height="15" bgcolor="6c513f"><div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Text 
              Text Text Text Text Text</strong></font></div></td>
          <td width="19"><img src="images/Template_003_04.png" width="16" height="15"></td>
        </tr>
        <tr> 
          <td colspan="3"><img src="images/Template_003_05.png" width="404" height="30"></td>
        </tr>
      </table>
      <table width="407"  border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td width="13"><img src="images/Template_003_06.png" width="13" height="100%"></td>
          <td width="375" bgcolor="ccb2a2"><div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Text 
              Text Text Text Text Text Text Text Text Text Text Text Text Text 
              Text Text Text Text Text Text Text Text Text Text Text Text Text 
              Text Text Text Text Text Text Text Text Text Text Text Text Text 
              Text Text Text Text Text Text Text Text Text Text</font></div></td>
          <td width="19"><img src="images/Template_003_08.png" width="16" height="100%"></td>
        </tr>
        <tr> 
          <td colspan="3"><img src="images/Template_003_12.png" width="404" height="55"></td>
        </tr>
      </table></td>
  </tr>
</table>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 08-02-06, 08:49 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 7,572
Thanks: 5
Thanked 27 Times in 24 Posts
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 08-02-06, 10:17 AM
Ares Ares is offline
Newbie Coder
 
Join Date: May 2006
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by nico_swd
I tried that method, but, im not sure if i did it wrong or anything, but the table didn't move, instead it did what it would normally do, higlight text and images.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 08-02-06, 10:43 AM
TwoD TwoD is offline
Community Liaison
 
Join Date: Sep 2003
Location: 404
Posts: 1,814
Thanks: 0
Thanked 0 Times in 0 Posts
Would you mind posting the code with the dragrop script in it? Makes it easier to see if something's wrong
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 08-02-06, 11:22 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 7,572
Thanks: 5
Thanked 27 Times in 24 Posts
Include the script following the description on the page, then put the tables you want to move between divs.

Code:
<div id="yourdiv" style="position:absolute;"><table> etc... </div>
This should do it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 08-02-06, 02:31 PM
Ares Ares is offline
Newbie Coder
 
Join Date: May 2006
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Ok, so now i have two tables dragable, but when i select table (content1) and drag, then go onto table two (content2) and drag it (the x- coverage of content1) from a point, "content1" moves instead of selecting "content2". May just be a fault in my code.

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Template_003</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<STYLE type="text/css">
 <!--
 BODY { 
               background-repeat:repeat-x;
               background-position:top center;
                }
HTML {
	OverFlow-y: Hidden;
	OverFlow-x: Hidden;
}
 -->
</STYLE>
<body bgcolor="74513b" background="images/bg.jpg">
<script type="text/javascript" src="wz_dragdrop.js"></script>

<div align="left" id="Content1" style="position:absolute; visibility: inherit;"> 
  <table width="39%"  border="0" cellspacing="0" cellpadding="0" name="Content Box">
    <tr> 
      <td height="169"><table width="407"  border="0" cellpadding="0" cellspacing="0">
          <tr> 
            <td colspan="3"><img src="images/Template_003_01.png" width="404" height="11"></td>
          </tr>
          <tr> 
            <td width="43"><img src="images/Template_003_02.png" width="43" height="15"></td>
            <td width="345" height="15" background="images/Template_003_03.png"><div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Text 
                Text Text Text Text Text</strong></font></div></td>
            <td width="19"><img src="images/Template_003_04.png" width="16" height="15"></td>
          </tr>
          <tr> 
            <td colspan="3"><img src="images/Template_003_05.png" width="404" height="30"></td>
          </tr>
        </table>
        <table width="407"  border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="13"><img src="images/Template_003_06.png" width="13" height="100%"></td>
            <td width="375" background="images/Template_003_13.png"><div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text</font></div></td>
            <td width="19"><img src="images/Template_003_08.png" width="16" height="100%"></td>
          </tr>
          <tr> 
            <td colspan="3"><img src="images/Template_003_12.png" width="404" height="55"></td>
          </tr>
        </table></td>
    </tr>
  </table>
</div>

<div align="left" id="Content2" style="position:absolute; left: 572px; top: 8px; visibility: inherit;"> 
  <table width="39%"  border="0" cellspacing="0" cellpadding="0" name="Content Box">
    <tr> 
      <td height="169"><table width="407"  border="0" cellpadding="0" cellspacing="0">
          <tr> 
            <td colspan="3"><img src="images/Template_003_01.png" width="404" height="11"></td>
          </tr>
          <tr> 
            <td width="43"><img src="images/Template_003_02.png" width="43" height="15"></td>
            <td width="345" height="15" background="images/Template_003_03.png"><div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Text 
                Text Text Text Text Text</strong></font></div></td>
            <td width="19"><img src="images/Template_003_04.png" width="16" height="15"></td>
          </tr>
          <tr> 
            <td colspan="3"><img src="images/Template_003_05.png" width="404" height="30"></td>
          </tr>
        </table>
        <table width="407"  border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="13"><img src="images/Template_003_06.png" width="13" height="100%"></td>
            <td width="375" background="images/Template_003_13.png"><div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text Text Text Text Text Text Text Text 
                Text Text Text Text Text Text</font></div></td>
            <td width="19"><img src="images/Template_003_08.png" width="16" height="100%"></td>
          </tr>
          <tr> 
            <td colspan="3"><img src="images/Template_003_12.png" width="404" height="55"></td>
          </tr>
        </table></td>
    </tr>
  </table>
</div>
  <script type="text/javascript">
<!--

SET_DHTML("Content2", "Content1");

//-->
</script>
</div>
</body>
</html>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 08-02-06, 03:16 PM
TwoD TwoD is offline
Community Liaison
 
Join Date: Sep 2003
Location: 404
Posts: 1,814
Thanks: 0
Thanked 0 Times in 0 Posts
The page works fine in IE and Opera. I noticed a problem in FF where the left table moves when you click on the right one.
This comes down to a problem with the <div> elements not having the correct widths.
It's easy to see if you have the Dev Toolbar in FF and outline all Absolutely positioned elements.

I corrected this by setting style.width to "" (which forces a recalculation of it) on the divs. Then the container divs shrank to the correct size.
I'm not sure if this problem is a side effect of some other error (it doesn't pass the W3C Validator), or what. I doubt it is a problem with the actual script since all the examples on http://www.walterzorn.com work in FF.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.

Last edited by TwoD; 08-02-06 at 03:19 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 08-02-06, 04:13 PM
Ares Ares is offline
Newbie Coder
 
Join Date: May 2006
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
I corrected this by setting style.width to "" (which forces a recalculation of it) on the divs. Then the container divs shrank to the correct size.
How do i set this? Sorry about all the questions, im very new to web coding.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 08-02-06, 04:30 PM
TwoD TwoD is offline
Community Liaison
 
Join Date: Sep 2003
Location: 404
Posts: 1,814
Thanks: 0
Thanked 0 Times in 0 Posts
You could add
Code:
document.getElementById('Content1').style.width="";
document.getElementById('Content2').style.width="";
right after
Code:
SET_DHTML("Content2", "Content1");
But that would just be a hack to get it working in FF, and it might break it for other browsers.

I suggest you try the Validator and fix all the issues it reports first, that might fix the cause of the problem and not just the symptoms (hopefully).
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 08-02-06, 05:18 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 7,572
Thanks: 5
Thanked 27 Times in 24 Posts
Since both tables have a set width, you could just add the same width to the divs.

Code:
<div align="left" id="Content1" style="position:absolute; width:407px;">
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML Tables Hunter HTML/XHTML/XML 4 06-04-06 04:05 PM
updating database tables when tables may or may not have changed? Tim Mousel PHP 0 05-21-06 05:25 PM
REQUEST: Tutorial or prmg on mysql/php/related tables chippewapublishing Script Requests 0 08-05-05 01:50 PM
tables joins - 3 tables lordmerlin ASP 1 03-18-04 08:20 AM
script that measures height of tables and vertically aligns nested tables amj01 Script Requests 1 07-04-03 01:20 PM


All times are GMT -5. The time now is 09:50 PM.
vBulletin® Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.