...

View Full Version : add text to cell (DHTML)



d_b_s
03-19-2004, 02:27 PM
Help me. I add table to DHTML-edit, code:
var pVar = document.ObjTableInfo;
pVar.NumRows = 3;
pVar.NumCols = 4;
pVar.TableAttrs = 'border=1';
pVar.CellAttrs = '';
pVar.Caption = tit;
obj_editor.ExecCommand(DECMD_INSERTTABLE,OLECMDEXECOPT_DODEFAULT, pVar);

where ObjTableInfo is object, CLASSID="clsid:47B0DFC7-B7A3-11D1-ADC5-006008A5848C"
I want create table with text in cells. How can I do it?

I am sorry for my English.

swmr
03-20-2004, 12:14 AM
It appears that the object has no metheds for that, as such, but exposes a DOM object, which can be used to manipulate data, etc.

Here are some references that might help you:
TD Element | td Object (http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/td.asp)
TABLE Element | table Object (http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/table.asp)
How to Build Tables Dynamically (http://msdn.microsoft.com/workshop/author/tables/buildtables.asp)
About the W3C Document Object Model (http://msdn.microsoft.com/workshop/author/dom/domoverview.asp)

DHTML Editing Component Constants (.vbs) (http://www.branz.org.nz/~branz/scripts/editor/Inc/dhtmled.vbs)

... and here's a simple test I did:


<html>
<head>
<title>-</title>

<script type="text/JScript">

function blah(){
var DOM, tableAttributes, cellAttributes, ITP, oCells;

DOM = DHTMLSafe.DOM;

tableAttributes =
"border = 1 " +
"frame = border " +
"rules = all " +
"width = 100% " +
"id = table1 ";

cellAttributes = "align = center";

ITP = new ActiveXObject("DEInsertTableParam.DEInsertTableParam");

ITP.NumRows = 5;
ITP.NumCols = 5;
ITP.Caption = "Hello...";
ITP.TableAttrs = tableAttributes;
ITP.CellAttrs = cellAttributes;

DHTMLSafe.ExecCommand(5022, 0, ITP);

oCells = DOM.getElementById("table1").cells;

for(var i = 0; i < oCells.length; i++){oCells[i].innerText = "blah";}
}
</script>

<style type="text/css">
div{text-align:center;margin:5px}
.editBox{width:50%;height:50%}
</style>

</head>
<body>

<div>
<object id="DHTMLSafe" class="editBox"
classid="clsid:2D360201-FFF5-11D1-8D03-00A0C959BC0A">

<param name="ActivateApplets" value="0">
<param name="ActivateActiveXControls" value="0">
<param name="ActivateDTCs" value="-1">
<param name="ShowDetails" value="0">
<param name="ShowBorders" value="0">
<param name="Appearance" value="1">
<param name="Scrollbars" value="-1">
<param name="ScrollbarAppearance" value="1">
<param name="SourceCodePreservation" value="-1">
<param name="AbsoluteDropMode" value="0">
<param name="SnapToGrid" value="0">
<param name="SnapToGridX" value="50">
<param name="SnapToGridY" value="50">
<param name="UseDivOnCarriageReturn" value="0">

</object>
</div>

<div><button onclick="blah();this.disabled=1">Insert Table</button></div>

</body>
</html>

d_b_s
03-22-2004, 12:38 PM
thank you :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum