/    Sign up×
Community /Pin to ProfileBookmark

table generator code to iframe

In the WYSIWYG editor I’m developing have a form table generator in a popup window. The table code is based form input (cols, rows, etc.) and is displayed in a textarea. This has to be copied and pasted into the source code of the web page under construction.

I want the table code to be inserted directly into the source code without copying and pasting it from the popup window. This would involve passing form output from a child window to an iframe embedded in the parent window. Any ideas on how would I script this?

<SCRIPT>
function makeTable() {
var rows = document.form.rows.value * 1
var cols = document.form.cols.value *
1
var width = document.form.width.value * 1
var border = document.form.border.value *
1
var cellpadding = document.form.cellpadding.value * 1
var align = document.form.align.value
var tdalign = document.form.tdalign.value
var bgcolor = document.form.bgcolor.value
if (bgcolor == “” || bgcolor == null) { bgcolor = “white” }
var valign = document.form.valign.value
var table = “<table width=”” + width + “”n”
table += ” border=”” + border + “”n”
table += ” cellpadding=”” + cellpadding + “”n”
table += ” align=”” + align + “”n”
table += ” bgColor=”” + bgcolor + “”n”
table += “n<!– –>nn”

var tdwidth = width / cols
for (i = 1; i <= rows; i++) {
table += “<!– Row ” + i + ” –>n”
table += “<tr>n”

for (t = 1; t <= cols; t++) {
table += “<td width=”” + tdwidth + “” align=”” + tdalign + “” valign=”” + valign + “”>n”
table += ” Row ” + i + “, Column ” + t +” n”
table += “</td>n”
}
table += “</tr>nn”
}
if (table.indexOf(“NaN”) != -1) {
table = “Sorry, there was an error generating your table.n”
table += “Please check all the fields and then try again.”
} else {
table += “</table>”
}
document.form.table.value = table //CHANGE THIS LINE TO WHAT?
document.form.table.focus() //ALSO CHANGE THIS LINE TO iframe.focus()?
}
</script>

<input type=”button” value=”Generate Code” onclick=”makeTable()”>
<br>
<textarea name=”table” rows=”10″ cols=”60″></textarea>

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @starrwriter spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...