Uses the HTMLArray values to populate each cell of table. Parameters : eTable : Table which has to be processed HTMLArray : Array of HTML Components that need to be used in the cells..
function insertRow(eTable, HTMLArray, CellFocus) { // Insert the row and set the color etc. var eRow = eTable.insertRow(); eRow.bgcolor ="#0000ff"; //Take each cell and process it. for (i=0; i < HTMLArray.length; i++) { varCell = eRow.insertCell(); varCell.bgColor = "#DAE9F8"; // varCell.align = "center"; varCell.insertAdjacentHTML('afterBegin', HTMLArray[i]); } //Finally set the focus to the recently added row. Note that focus is returned to the First Cell in the row. //Assumption is that Cell(0) is the select Control. Cell(1) is where the user would like to start the data //entry. var NoOfRows = eTable.rows.length - 1; eTable.rows(NoOfRows).cells(CellFocus).childNodes(0).focus(); } On 12/19/05, JEEVANATHAM P. /BPCRP/INFOTECH/VASHI < [EMAIL PROTECTED]> wrote: > > Same way I need to create a table and all fields are editable when user > double clicks. > Irfan can you tell me how can we create a new row using java script? > > > -----Original Message----- > From: Irfan Shaikh [mailto:[EMAIL PROTECTED] > Sent: Monday, December 19, 2005 1:12 PM > To: Struts Users Mailing List > Subject: Re: Implementation of new row functionality of HTML table in > Struts > > No, user can add has many row he needed before submit... I had just added > one row to handle this scenario... It should work for as many row user has > added... > > > On 12/19/05, atta-ur rehman <[EMAIL PROTECTED]> wrote: > > > > okay, so you're saying use can add only ONE row dynamically before > submit? > > and that the newly added row's HTML code is: > > > > <tr> > > <td><input type="checkbox" name="id" value="yes"></td> > > <td><input type="text" name="customer[4].firstName" > > value="John"></td> > > <td><input type="text" name="customer[4].lastName" > > value="Mark"></td> > > <td><input type="text" name="customer[4].address" value="New > > York"></td> > > </tr> <!--This is the HTML of hardcoded row--> > > > > > > if that's the case, in your ActionForm's reset method, detect that user > > has > > added a new row, maybe thru request.getParameter > ("customer[?].firstName") > > where ? will be an integer 0..n where reuqest.getParameter would return > > null > > for n+1. once you've done that do a: > > > > Customer[] customers = new Customer[n]; > > form.set("customer", customers); > > > > see if that helps. > > > > ATTA > > > > > > On 12/18/05, Irfan Shaikh <[EMAIL PROTECTED]> wrote: > > > > > > Once again Generated HTML : > > > > > > <form name="listTextForm" method="post" > > > action="/GenerateHTMLTable/listtext.do"> > > > > > > <input type="submit" value="Submit"> > > > <br> > > > <table width="30%" border="0"> > > > <colgroup> > > > > > > <COL width="5"> > > > <COL width="30"> > > > <COL width="30"> > > > <COL width="35"> > > > </colgroup> > > > > > > <!--Session Scope --> > > > > > > <tr> > > > <td><input type="checkbox" name="id" value="yes"></td> > > > <td><input type="text" name="customer[0].firstName" > > > value="Irfan"></td> > > > > > > <td><input type="text" name="customer[0].lastName" > > > value="Shaikh"></td> > > > <td><input type="text" name="customer[0].address" value="New > > > Mumbai"></td> > > > </tr> > > > > > > <tr> > > > <td><input type="checkbox" name="id" value="yes"></td> > > > <td><input type="text" name="customer[1].firstName" > > > value="Maruf1212"></td> > > > <td><input type="text" name="customer[1].lastName" > > > value="Dolani"></td> > > > <td><input type="text" name="customer[1].address" > > > value="Mumbai"></td> > > > </tr> > > > > > > <tr> > > > <td><input type="checkbox" name="id" value="yes"></td> > > > > > > <td><input type="text" name="customer[2].firstName" > > > value="Azima121111"></td> > > > <td><input type="text" name="customer[2].lastName" > > > value="Kacchi"></td> > > > <td><input type="text" name="customer[2].address" > > > value="Pune"></td> > > > </tr> > > > > > > <tr> > > > <td><input type="checkbox" name="id" value="yes"></td> > > > <td><input type="text" name="customer[3].firstName" > > > value="Ruhi11133"></td> > > > <td><input type="text" name="customer[3].lastName" > > > value="Khan"></td> > > > <td><input type="text" name="customer[3].address" > > > value="Pune"></td> > > > </tr> > > > > > > > > > <tr> > > > <td><input type="checkbox" name="id" value="yes"></td> > > > <td><input type="text" name="customer[4].firstName" > > > value="John"></td> > > > <td><input type="text" name="customer[4].lastName" > > > value="Mark"></td> > > > <td><input type="text" name="customer[4].address" value="New > > > York"></td> > > > </tr> (Hardcoded HTML row) > > > > > > </table> > > > > > > > > > </form> > > > > > > > > > > > > -- > Greetings! > > > > > ICICI Infotech is now 3i Infotech. > > > The e-mail addresses of the company's employees have been changed to > <existing name>@3i-infotech.com. You are requested to take note of this > new e-mail ID and make use of the same in future > > > "This e-mail message may contain confidential, proprietary or legally > privileged information. It should not be used by anyone who is not the > original intended recipient. If you have erroneously received this message, > please delete it immediately and notify the sender. The recipient > acknowledges that 3i Infotech or its subsidiaries and associated companies, > (collectively "3i Infotech"), are unable to exercise control or ensure or > guarantee the integrity of/over the contents of the information contained in > e-mail transmissions and further acknowledges that any views expressed in > this message are those of the individual sender and no binding nature of the > message shall be implied or assumed unless the sender does so expressly with > due authority of 3i Infotech. Before opening any attachments please check > them for viruses and defects." > > >