JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old February 10th, 2005, 10:46 AM
Avie Avie is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 2 Avie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 37 sec
Reputation Power: 0
execCommand - insert table

I am working on a wysiwyg editor that needs to have some table editing functionality. The existing table insertion function simply pastes the appropriate html using loops to get the requested number of rows and columns. After the HTML has been pasted, the user cannot alter the number of rows or columns without editing the html itself (which pretty much defeats the purpose of the editor!) I did a little research and found that the execCommand Method has more command identifiers that what are listed at http://msdn.microsoft.com/workshop/author/dhtml/reference/commandids.asp More specifically one called DECMD_INSERTTABLE that is defined as 5022 in dhtmled.js.

I have been trying DESPERATELY to find some documentation on how to use DECMD_INSERTTABLE, but all I have found so far are some examples that don't entirely work. I've pieced together a function from the examples and the documentation on execCommand. No errors are caused when my function using execCommand('DECMD_INSERTTABLE', 0, document.mytableinfo) is called, but nothing seems to happen at all. No error, no results, no nothing.

My code is as follows (Irrelevant code imbetween has been omitted):


(Omitted lines of code ...)

<a href="javascript: tableMultiComTest(5022, document.mytableinfo);"><img src="images/table.gif" border="0" alt="Insert Table" /></a>

(More omitted lines ... )

<script languange="Javascript" src="scripts/DHtmled.js">
</script>
<script languange="Javascript">
function tableMultiComTest(aValue, aOption)
{
if (document.all["DivArea"].style.visibility == "visible")
{
document.all["DivArea"].focus();
if (aOption=="removeFormat")
{
aValue=aOption;
aOption=null;
}
if (aOption==null)
{
document.execCommand(aValue);
}
else
{
if (aValue == 5022)
{
tableProps = new tableattr(2, 2, 'width="80%" border=1');

<!--- document.mytableinfo.NumRows=1;
document.mytableinfo.NumCols=2;
document.mytableinfo.Border=1;
document.mytableinfo.TableAttrs = ' width="100%"';
document.mytableinfo.CellAttrs = ' bgColor="blue" noWrap';
document.mytableinfo.Caption = "New Table "; --->
}
var sel=document.selection.createRange();
sel.execCommand(aValue, true, tableProps);
}
document.all["DivArea"].focus();
}
else
{
alert("Please Select the Preview Mode before selecting this option.");
}
}
</script>
<object ID="mytableinfo" CLASS="mytableinfo" CLASSID="clsid:47B0DFC7-B7A3-11D1-ADC5-006008A5848C"></object>

If anyone knows anything about what the problem could be or knows of and good documentation or examples for DECMD_INSERTTABLE or any of the other functions defined in dhtmled.js, PLEASE let me know! Thanks.

-Avie

Reply With Quote
  #2  
Old February 10th, 2005, 01:54 PM
Avie Avie is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 2 Avie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 37 sec
Reputation Power: 0
Talking Nevermind - Here is a much simpler solution

Nevermind my question. I've found a much simpler solution. Here is the example I found:
http://www.mozilla.org/docs/dom/technote/tn-dom-table/#getting

Much easier and there are tons of ways to edit the table also. You can find them here:

http://msdn.microsoft.com/workshop/author/dhtml/reference/methods.asp

Just incase anyone else is trying to do the same thing!

-Avie

Reply With Quote
  #3  
Old February 21st, 2005, 03:39 AM
villek villek is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 2 villek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 5 sec
Reputation Power: 0
Hi!

I'm currently battling with creating tables with my wysiwyg editor.

You wouldn't happen to have and be wiling to share a bit of your code? I'm a bit of a nood when it comes to javascript and DOM (more familiar with php) and I waould like to see a very simple table inserting function.

My setup works so that I have no popups, just div's which I hide or show depending on what the user is doing (i.e editing img props, editing table props [not rdy yet] etc.). So basically I would like to see an example where data from a form goes into a js function which then creates a table into the editor iframe.

I know that I should just go and code the example myself, but since time is money, I thought I'd ask if someone would have a stripped down example of this.

Thanks in advance!

Reply With Quote
  #4  
Old February 21st, 2005, 05:29 AM
villek villek is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 2 villek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 5 sec
Reputation Power: 0
Ok, atm I've created a script to create the table and I'm able to choose, how many rows and cols it has.

If someone would like to share on manipulating the table (deleting rows/cols/cells etc.) and communicating between the table and the form that retrieves the tables props, I would be a happy little camper.

Basically I need help in determining which, for example, row I'm trying to edit and in which table the row is in case there are multiple tables, and getting that information into the editing also?

Cheers.

Reply With Quote
  #5  
Old February 21st, 2005, 08:08 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
Here's a guide about Traversing the HTML Table with JavaScript and DOM interfaces

It should help you dynamically create the table using Javascript & DOM; there are some good examples.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > execCommand - insert table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway