472,787 Members | 1,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,787 software developers and data experts.

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

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.
Jul 23 '05 #1
2 2890
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>

Jul 23 '05 #2
Excellent. That's exactly the sort of thing. Is it possible to make
the cells editable?
mscir <ms***@access4less.net> wrote in message news:<10*************@corp.supernews.com>...
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>

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: newbie_mw | last post by:
Hi, I need urgent help with a novice problem. I would appreciate any advice, suggestions... Thanks a lot in advance! Here it is: I created a sign-up sheet (reg.html) where people fill in their...
1
by: newbie_mw | last post by:
Seems my post was buried in more cries for help :-) I will try again. It's probably a very novice question so please take a look! Thanks!...
4
by: lawrence | last post by:
Google can't find me a good example of how to use the "if exists" syntax in MySql. Is it right that to use it this way: INSERT INTO IF EXISTS tMyTable VALUES("xxlk", "lkjlkjlkjljk") I want...
5
by: Chad Richardson | last post by:
Is there a way in SQL Server 2000 to extract data from a table, such that the result is a text file in the format of "Insert Into..." statements, i.e. if the table has 5 rows, the result would be 5...
6
by: Rich | last post by:
Hello, I have to create a table in an Access mdb (remotely) on the fly. Create Table tbl1(fld1 Integer, fld2 varchar(10), fld3...) Then I have to insert data: Insert Into tbl1 Values(" &...
20
by: Mark Harrison | last post by:
So I have some data that I want to put into a table. If the row already exists (as defined by the primary key), I would like to update the row. Otherwise, I would like to insert the row. I've...
0
by: MarceloLinero | last post by:
Hi, i`m problem whith it !! help me ! No found way for insert in table directy in database sql express and no undertand why ! steps in general: 1. create coneccion ready 2. declarate a...
5
by: djsdaddy | last post by:
Good Day All, I have some EEO data in an old dBase4 database that I have converted to an Access table. Since dBase was not a relational database, I didn't create any key fields. I linked all of the...
3
by: Twanne | last post by:
Hi, I've got a table called Aerosol and a table called LinkTabel. Now I do an update to a table from an excell sheet, this table is called ExportAerosol. So far so good, the import works...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.