need help dynamically creating forms with DOM

N

NewmanBT

I'm trying to create a fairly simple form which contains a label, a
button, and a textbox.
I've done quite a bit of reading and, from what I can figure, the
following should work, but isn't.

var rowCommentBox = document.createElement("TR");
var cellCommentBox = document.createElement("TD");
var frmCommentBox = document.createElement("FORM");
frmCommentBox.setAttribute("METHOD", "POST");
var strAction = "\"submitComments.asp?Org=\"+strOrg+\"&date=\"+activeWeekBegins\""
frmCommentBox.setAttribute("ACTION", strAction);
var rowFrmCommentBox = document.createElement("TR");
var cellFrmCommentBoxLabel = document.createElement("TD");
var strFrmCommentLabel = document.createTextNode("comment:");
var cellFrmCommentBoxButton = document.createElement("TD");
var btnFrmCommentBoxButton = document.createElement("INPUT");
btnFrmCommentBoxButton.setAttribute("TYPE", "SUBMIT");
btnFrmCommentBoxButton.setAttribute("VALUE", "UPDATE");
var cellFrmCommentBoxTxtbx = document.createElement("TD");
var txtbxFrmCommentBoxTxtbx = document.createElement("INPUT");
txtbxFrmCommentBoxTxtbx.setAttribute("TYPE", "TEXT");
txtbxFrmCommentBoxTxtbx.setAttribute("cols", "50");
txtbxFrmCommentBoxTxtbx.setAttribute("VALUE", strComments);

cellFrmCommentBoxLabel.appendChild(strFrmCommentLabel);
rowFrmCommentBox.appendChild(cellFrmCommentBoxLabel);
cellFrmCommentBoxButton.appendChild(btnFrmCommentBoxButton);
rowFrmCommentBox.appendChild(cellFrmCommentBoxButton);
cellFrmCommentBoxTxtbx.appendChild(txtbxFrmCommentBoxTxtbx);
rowFrmCommentBox.appendChild(cellFrmCommentBoxTxtbx);
frmCommentBox.appendChild(rowFrmCommentBox);
rowCommentBox.appendChild(frmCommentBox);
tbodyOrgToAdd.appendChild(rowCommentBox);

help would be greatly appreciated.
 
K

kaeli

I'm trying to create a fairly simple form which contains a label, a
button, and a textbox.
I've done quite a bit of reading and, from what I can figure, the
following should work, but isn't.
What happens? Do you get an error? What browser?
help would be greatly appreciated.

Full working (or not, as the case may be *LOL*) example would be
appreciated if you want debugging help. ;)



--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top