Jump to content

hugebob

Members
  • Content Count

    7
  • Joined

  • Last visited

Community Reputation

0 Neutral

About hugebob

  • Rank
    Newbie
  1. When you submit the form, can you check and see that those dynamically created inputs are actually received? This is just maddening.
  2. DF, I gave this a try: adding the new elements to the tbody. But, still no go. I started off my base table like this: <table ...><tbody></tbody></table> I then altered my Javascript code to this: FileControlSet.prototype.addRow = function ( ) { var table = document.getElementById(this.id); var tbody = table.getElementsByTagName("tbody"); var insertionIndex = 0; if (tbody[0].rows.length < this.maxNumberOfFileControls) { insertionIndex = tbody[0].rows.length; var newTableRow = tbody[0].insertRow(insertionIndex); var newTableCell = document.createElement("td"); newTableRow.appendChild(newTableCell); var paragraph = document.createElement("p"); var inputLabelText = "" + (insertionIndex+1) + ". Upload File:"; paragraph.appendChild(document.createTextNode(inputLabelText)); newTableCell.appendChild(paragraph); var fileUploadControl = document.createElement("input"); fileUploadControl.setAttribute("type", "FILE"); fileUploadControl.setAttribute("name", "upload"+insertionIndex); fileUploadControl.setAttribute("id", "upload"+insertionIndex); fileUploadControl.setAttribute("size", "50"); fileUploadControl.setAttribute("class", "myInputs"); newTableCell.appendChild(fileUploadControl); }};
  3. Yes. Here's the form tag: <form action="blah.do" name="myform" id="myform" method="post" onSubmit="return ValidateForm(this)" enctype="multipart/form-data">
  4. Nope, no errors. Viewing console in Firebug, I can see the new controls being added to the DOM and I can see them and interact with them on the page. However, stepping through the onSubmit handler, references to those controls are undefined.
  5. Dsonesuk, I tried starting off with: <table id="uploadControlTable" width="100%" border="0" cellpadding="0" cellspacing="0"><tbody></tbody></table> But that didn't work.
  6. Hey JamesB, Here's my JS code that adds the form fields: function FileControlSet(tableID, maxControls){ this.id = tableID; this.maxNumberOfFileControls = maxControls; this.insertionIndex = 0;} FileControlSet.prototype.addRow = function ( ) { var table = document.getElementById(this.id); var rows = table.getElementsByTagName("tr"); var insertionIndex = 0; if (rows.length < this.maxNumberOfFileControls) { insertionIndex = rows.length; var newTableRow = table.insertRow(insertionIndex); var newTableCell = document.createElement("td"); newTableRow.appendChild(newTableCell); var paragraph = document.createElement("p"); var inputLabelText = "" + (insertionIndex+1) + ". Upload File:"; paragraph.appendChild(document.createTextNode(inputLabelText)); newTableCell.appendChild(paragraph); var fileUploadControl = document.createElement("input"); fileUploadControl.setAttribute("type", "FILE"); fileUploadControl.setAttribute("name", "upload"+insertionIndex); fileUploadControl.setAttribute("id", "upload"+insertionIndex); fileUploadControl.setAttribute("size", "50"); fileUploadControl.setAttribute("class", "myInputs"); newTableCell.appendChild(fileUploadControl); }}; The page creates this object by doing: <script type="text/javasript"> fileUploadControls = new FileControlSet('uploadControlTable', 40);</script> An empty HTML table is within the form tags: <table id="uploadControlTable" width="100%" border="0" cellpadding="0" cellspacing="0"></table>This is the table where the file inputs are created and do so just fine. But, they're not showing up in the form structure.
  7. Hi All, I've written some Javascript that will dynamically add "file" inputs to a form. They show up on the page just fine when the add control is clicked. But, when I submit the form, those dynamically added form fields are absent from the form structure on the receiving page. They're also absent from the form structure passed to the validation function. The added fields are added to a table within the form tags. The JS code adds table rows (TR). Then, cells are added to that row. Then, the file inputs to the cells. All this is done using DOM methods like appendChild(), createElement(), createTextNode(), etc. Is there some extra step needed to make sure the added fields are made part of the form?
×
×
  • Create New...