Adding a table within a fieldset

Hi there,
I am trying to add a table within a fieldset, but the table does not get inserted into the fieldset.  It comes below the fieldset.
var createDateTimeSection = function() {
        var mainTable = document.createElement("table");        
        var dateTimeFieldSet = document.createElement("fieldset");
        var dateTimeFieldSetLegend =  document.createElement("legend");
        var innerForm = document.createElement("form");
        var innerTable = document.createElement("table");
        var dateTimeRow = document.createElement("tr");
        var fromCol = document.createElement("td");
        var toCol = document.createElement("td");
        var dateTimeTextBoxRow = document.createElement("tr");
        var fromTextBoxCol = document.createElement("td");
        var toTextBoxCol = document.createElement("td");
        

        var fromDate = document.createElement("input");
        fromDate.maxLength = "24";
        fromDate.style.width = "80px";
        fromDate.id ="FromDatePicker";
        fromDate.type = "text";
        
        fromCol.appendChild(fromDate);

        var toDate = document.createElement("input");
        toDate.maxLength = "24";
        toDate.style.width = "80px";
        toDate.id = "ToDatePicker";
        toDate.type = "text";
        
        toCol.appendChild(toDate);
        dateTimeRow.appendChild(fromCol);
        dateTimeRow.appendChild(toCol);
        
        var fromText = document.createElement("input");
        fromText.style.width = "80px";
        fromText.id = "fromDateTextFieldID";
        fromText.type = "text";
        
        fromTextBoxCol.appendChild(fromText);
        
        var toText = document.createElement("input");
        toText.style.width = "80px";
        toText.id = "toDateTextFieldID";
        toText.type = "text";
        
        toTextBoxCol.appendChild(toText);
        
        dateTimeTextBoxRow.appendChild(fromTextBoxCol);
        dateTimeTextBoxRow.appendChild(toTextBoxCol);
        
        dateTimeFieldSetLegend.innerHTML = "Date and Time";
        dateTimeFieldSet.appendChild(dateTimeFieldSetLegend);
        innerTable.appendChild(dateTimeRow);
        innerTable.appendChild(dateTimeTextBoxRow);
        innerForm.appendChild(innerTable);
        dateTimeFieldSet.appendChild(innerForm);
        mainTable.appendChild(dateTimeFieldSet);
        return mainTable;
    };

Open in new window

ambuliAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobOwner (Aidellio)Commented:
I've copied your code and it looks ok to me: http://jsbin.com/woxiyu/1/edit?js,console,output

How are you inserting the code created from that function?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chaauCommented:
works well in IE and firefox. I got this body:
<body>
    test
    <script language="JavaScript">document.body.appendChild(createDateTimeSection());</script>
</body>

Open in new window

And here's the result:datetimetest.html
ambuliAuthor Commented:
Thank you.  I am using this function inside a jquery-steps (http://www.jquery-steps.com/) code.
Below is the calling code.  So, it only doesn;t work inside the wizard.

var initDialog= function(wizardDiv){
         var stepOne = document.createElement("h3");
        stepOne.innerText = "Test";
        var sectOne = document.createElement("section");
        var sectOneDetails = __selectReportType();

        var stepTwo = document.createElement("h3");
        stepTwo.innerText = "Date and Time";
        var sectTwo = document.createElement("section");
        var sectTwoDetails = createDateTimeSection();
        
        wizardDiv.appendChild(stepOne);
        sectOne.appendChild(sectOneDetails);
        wizardDiv.appendChild(sectOne);

        wizardDiv.appendChild(stepTwo);
        sectTwo.appendChild(sectTwoDetails);
        wizardDiv.appendChild(sectTwo);
        
        var mySteps = $(wizardDiv).steps({
            headerTag: "h3",
            bodyTag: "section",
            transitionEffect: "slideLeft",
            autoFocus: true,
            enableCancelButton:true,

            onCanceled: function (event) {
                console.log("cancelled......");
                $(wizardDiv).dialog("close");
                $(wizardDiv).remove();
            }
        });

Open in new window

ambuliAuthor Commented:
Thank you guys- It turned out that returning the fieldset from the function instead of the table fixed it.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.