|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Managing the Dynamic created HTML table thru javascript
hi
i had created an table using javascript: " <html> <head> <title>Dynamically Add Table Row</title> <script language="JavaScript" type="text/javascript"> function showcalendar(Rowid) { alert(Rowid); } function Savedetails() { //var Dcode = document.getElementById("htnDcode").value; //var Dcode = document.FrmDCode.btnSave.value ; var Dcode = document.all.table1.innerHTML; //var Dcode = eval(document.all.table1.txtDcode.value); //var Dcode = document.all.table1.txtDcode1.Value; alert(Dcode); var Dcount = document.getElementById("htncount").value; alert(Dcount); for(var cnt= 1 ;cnt<=Dcount;cnt++) { var Dcodeold = document.getElementById("htnDcode").value; var DcodeNew = eval("document.getElementById('txtDcode"+cnt+"').value"); document.getElementById("htnDcode").value = Dcodeold + "|" +DcodeNew ; //var Dcount = document.getElementById("txtDcode"+cnt).value; //alert("document.getElementById(\""txtDcode"+cnt+"\"").value"); } alert(document.getElementById("htnDcode").value); } function delRow(TDid,TRid,RowId) //function delRow(TDid,TRid) { selTD = document.getElementById(TDid); selTR = document.getElementById(TRid); intRowSpan = selTD.getAttribute("rowSpan"); intRowIndex = selTR.getAttribute("rowIndex"); intInsPos = intRowSpan + intRowIndex ; //alert(RowId); //alert("intRowSpan:" + intRowSpan); //alert("intRowIndex:"+ intRowIndex); document.all.table1.deleteRow(RowId); //document.all.table1.deleteRow(this.intRowIndex); //document.all.table1.deleteRow(this.intRowSpan); //document.all.table1.deleteRow(intInsPos-1); //selTD.setAttribute("rowSpan",selTD.getAttribute("rowSpan")-1); } function insRow(TDid,TRid) { selTD = document.getElementById(TDid); selTR = document.getElementById(TRid); intRowSpan = selTD.getAttribute("rowSpan"); intRowIndex = selTR.getAttribute("rowIndex"); intInsPos = intRowSpan + intRowIndex ; var oTR = document.all.table1.insertRow(intInsPos); //var RowId = intInsPos - 2 ; var RowId =intInsPos; var oC1TD = oTR.insertCell(0); oC1TD.innerHTML = "<input type=text id=txtDcode"+RowId+" runat=server value="+RowId+">"; var oC2TD = oTR.insertCell(1); oC2TD.innerHTML = "<input type=text id=txtDper"+RowId+" runat=server>"; var oC3TD = oTR.insertCell(2); oC3TD.innerHTML = "<input type=text id=txtNoUses"+RowId+" runat=server>"; var oC4TD = oTR.insertCell(3); oC4TD.innerHTML = "<input type=text id=txtExpDate"+RowId+" runat=server>"+" <img id=img"+RowId+" src=./images/action/calender1.gif onclick=showcalendar("+intInsPos+")>"; var oC5TD = oTR.insertCell(4); oC5TD.innerHTML = "<input type=button runat=server value=delete onclick=delRow('mondayTD','mondayTR','"+intInsPos+"')>"; //oC5TD.innerHTML = "<input type=button runat=server value=delete onclick=delRow('mondayTD','mondayTR')>"; /*alert(oC1TD.innerHTML); alert(oC2TD.innerHTML); alert(oC3TD.innerHTML); alert(oC4TD.innerHTML); alert(oC5TD.innerHTML);*/ //alert(oTR.innerHTML); //alert(TRid); document.getElementById("htncount").value = RowId; selTD.setAttribute("rowSpan",selTD.getAttribute("rowSpan")+1); } </script> </head> <body> <form id="FrmDCode" runat="server"> <table id="table1" width="100%" border="1"> <tr> <td colspan="6"> <input type="button" value="ADD" onclick="insRow('mondayTD','mondayTR')"> <!--<input type="button" value="-" onclick="delRow('mondayTD','mondayTR')">--> </td> </tr> <tr> <td> </td> <td>Discount Code</td> <td>Discount Percentage</td> <td>Number Of Uses</td> <td>Expiry Date</td> <td>Action</td> </tr> <tr id="mondayTR" valign="bottom"> <td id="MondayTD"> </td> </tr> </table> <table width="100%" runat="server" cellpadding="0" cellspacing="0" border="0"> <tr> <td> <input type="button" runat="server" id="btnSave" value="save" onclick="Savedetails()"> </td> </tr> <tr> <td> <input type=hidden runat=server id=htnDcode> <input type=hidden runat=server id=htncount> </td> </tr> </table> </form> </body> </html> " my case is : i had created 5 rows :: r1 r2 r3 r4 r5 first i had deleted r4 and then r2 then r5 , i am getting an error msg during this process .. can any one help on this regard ! |
![]() |
| Viewing: SEO Chat Forums > Other > HTML Coding > Managing the Dynamic created HTML table thru javascript |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|