Home | Products | Consulting | Hosting | Forums | Support | Order | 1-800-752-0455
  Main
Index
Search
Posts
Who's
Online
Log
In

Home: General: Off Topic Conversations:
DHTML Tables help

 

 


aXi
New User

Sep 14, 2003, 11:35 PM

Post #1 of 1 (4428 views)
Shortcut
DHTML Tables help Can't Post

First of all i would like to thank in advance anyone who will post anything helpful in reply to my problem. Seeing work of ppl here on forum I was kind of ashmed to post this... so plz don't make too much joke out of me ;).

Now, the problem is that I can't get DHTML tables to work fine. You can get the point what i want to do from just looking at the source code (you can find html with same code on this link - http://www.clan-g.com/aXi/table.html):

-----
<BUTTON onclick='javascript:InsertTable();space.focus();'
unselectable="on" align="center">Insert Table</BUTTON>
<BUTTON onclick='javascript:DeleteCell();space.focus();'
unselectable="on" align="center">Delete Cells</BUTTON>
<BUTTON onclick='javascript:DeleteRow();space.focus();'
unselectable="on" align="center">Delete Row</BUTTON>
<BR>

<DIV id=space contentEditable=true style="BORDER-RIGHT: darkblue 1px solid; BORDER-TOP: darkblue 1px solid; BORDER-LEFT: darkblue 1px solid; WIDTH: 500px; BORDER-BOTTOM: darkblue 1px solid; HEIGHT: 500px"></DIV>

<script language="JScript">
var oTable = space.document.createElement("Table");
var oRow, oCell, curr_row;

function InsertTable()
{
oTable.border = 1;
oTable.width = 75;

oRow = oTable.insertRow();
oRow.insertCell();
oRow.insertCell();
oRow.insertCell();
oRow = oTable.insertRow();
oRow.insertCell();
oRow.insertCell();
oRow.insertCell();
oRow = oTable.insertRow();
oRow.insertCell();
oRow.insertCell();
oRow.insertCell();

space.appendChild(oTable);
}

function DeleteRow()
{
oTable.deleteRow();
}

function DeleteCell()
{
for (curr_row = 0; curr_row < oTable.rows.length; curr_row++)
{
oTable.rows[curr_row].deleteCell();
}

}
</script>
-----

It's obvious what I want to do - to be able to bind scripts to buttons so I can with single click insert table and then delete it's cells or rows. Problem is - I can't insert rows or cells there where I WANT THEM or where currently mouse cursor is, DHTML with it's commands adds or deletes cells/rows on the end of table and that's it. I know that somehow I should include some what_is_selected but i do not know DHTML&JScript good so this is all I could make.

Also there are some other problems:
1. I can't get two tables inserted (my guess is that problem is var oTable outside of InsertTable function... but I need it there for DeleteRow and DeleteCell functions, or not?). Of course I want table to be inserted where cursor currently is...
2. DeleteCell do not work properly when there are no rows left... it leaves one row and then inserting new table makes problem (extra row with no cells).
3. I can't get InsertRow() and InsertCell() to work properly so i left them out. If someone can help me to make them to work in same manner like DeleteRow() and DeleteCell() - to add insted to delete line of cells/row there where curser resides that would help me a lot also.
4. It would be cool if someone gived me a hint on how to enable/disable buttons for inserting/deleting rows/cells depending on fact is table selected or is it not.

Once again tnx for any help. If it is easier, you can mail me at pele@beotel.yu.

c-ya guys...

 
 
 


Search for (options)
Products
CMS Builder
Article Manager
Realty Manager
Listings Manager
Order Now
Services
Priority Consulting
Hosting
Support
Online Documentation
Support Forums
Support Homepage
Company Info
12 reasons to choose us!
Meet the team
Monthly newsletter
Contact Us
Toll Free: 1-800-752-0455
Phone: (604) 689-3347
Sales | Support
Conditions of Use | Privacy Policy | Copyright © interactivetools.com 2008
#201 - 2730 Commercial Drive, Vancouver BC Canada V5N 5P4