Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Creating an "Insert table function" for use in an Iframe

Reply
Thread Tools

Creating an "Insert table function" for use in an Iframe

 
 
David Bradbury
Guest
Posts: n/a
 
      11-02-2004
I currently have an iframe on a webpage into which users can insert
content. They can further customise the text as I've included buttons
such as Bold, Italic, Bullet point etc. This is done along the lines
of

<td><div class="cbtn" onClick="cmdExec('bold',idContent)"
onmouseover="button_over(this);" onmouseout="button_out(this);"
onmousedown="button_down(this);" onmouseup="button_up(this);">
<img hspace="1" vspace=1 align=absmiddle src="images/Bold.gif"
alt="Bold">
</div></td>

But has anyone found a way of creating a table for insertion in an
Iframe. A much bigger task I realise but I'm not keen on users copying
tables from Word and inserting them into the iframe.
 
Reply With Quote
 
 
 
 
David Bradbury
Guest
Posts: n/a
 
      11-03-2004
Excellent. That's exactly the sort of thing. Is it possible to make
the cells editable?


mscir <> wrote in message news:<>...
> David Bradbury wrote:
>
> <snip>
> > But has anyone found a way of creating a table for insertion in an
> > Iframe. A much bigger task I realise but I'm not keen on users copying
> > tables from Word and inserting them into the iframe.

>
> How about this approach:
>
> <script type="text/javascript">
> function buildiframetable() {
> var f = document.forms['form1'];
> var tdpad = +f.tdpad.value;
> var tdspace = +f.tdspace.value;
> var tborder = +f.tborder.value;
> var rows = +f.rows.value;
> var cols = +f.cols.value;
> var d = document.getElementById('iframe1').contentWindow.d ocument;
> var table = d.createElement('table');
> table.border = tborder;
> table.cellPadding = tdpad;
> table.cellSpacing = tdspace;
> var tbody = d.createElement('tbody');
> for (var i=0; i<rows; i++) {
> var row = d.createElement('tr');
> for (var j=0; j<cols; j++) {
> var cell = d.createElement('td');
> cell.appendChild(d.createTextNode(i + ', ' + j));
> row.appendChild(cell);
> }
> tbody.appendChild(row);
> }
> table.appendChild(tbody);
> d.body.appendChild(table)
> }
> </script>
> </head>
>
> <body>
> <p>Build Table Dynamically with Javascript</p>
> <form name='form1' id='form1'>
> <br><b>Table Parameters</b>
> <br>Rows&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
> <input type="text" name="rows" id="rows" size="10" value="4">
> <br>Columns&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> <input type="text" name="cols" id="cols" size="10" value="6">
> <br>Border Thickness <input type="text" name="tborder" id="tborder"
> size="6" value="6">
> <br>Cell Spacing <input type="text" name="tdspace" id="tdspace"
> size="10" value="2">
> <br>Cell Padding <input type="text" name="tdpad" id="tdpad" size="10"
> value="2">
> <br><input type="button" value="Build Iframe Table"
> onclick="buildiframetable()">
> </form>
> <hr>
> <iframe name='iframe1' id='iframe1' width=300 height=300></iframe>
> </body>
> </html>

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to use an iframe as a link (make the whole iframe clickable) mi HTML 4 05-21-2008 10:13 PM
Targeting a parent iframe from a sub-iframe albanitus@yahoo.com HTML 0 11-15-2006 04:40 PM
Place table/iframe/whatever on top of a table AngTalunin Javascript 0 04-18-2005 03:31 PM
IFRAME - Refresh Table on Parent Window - maintain IFRAME State Scott ASP General 6 04-14-2004 05:48 AM
Get form values from iframe (1) to iframe (2) inside a layer in iframe (1) Daedalous Javascript 3 01-16-2004 11:08 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57