/    Sign up×
Community /Pin to ProfileBookmark

dyn. appending form ele. to display and form?

I can, for the most part, create new td’s and tr’s dynamically and get form elements added to table cells, but my problem is how to get them additionally into the form? Is it just a matter of naming?

instead of
var ourtable=document.getElementById(‘table1’);
var tb=document.createElement(‘tbody’);

var tr=document.createElement(‘tr’); // – now create the tr and td elements

var td=document.createElement(‘td’);

var name = “textbox” + num;
[COLOR=red]var yourName=document.createElement(‘input'[/COLOR] );
yourName.setAttribute(‘type’,’text’);
yourName.setAttribute(‘name’,name);
yourName.setAttribute(‘value’,”);
td.appendChild(yourName);
tr.appendChild(td);

should it be something like
[COLOR=red]var document.form1.elements.yourName=document.createElement(‘input’[/COLOR]

???

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangApr 28.2004 — If the table is within the form then the created [I]input[/I] will be part of the form.

You still have to add the table row to the table:

ourtable.appendChild(tb).appendChild(tr);

Of [URL=http://www.quirksmode.org/index.html?/dom/innerhtml_old.html]interest[/URL]
Copy linkTweet thisAlerts:
@furious70authorApr 28.2004 — that was it, inbetween my processing code I had misplaced the start of the form, thanks!
×

Success!

Help @furious70 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.19,
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,
)...