469,294 Members | 1,940 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,294 developers. It's quick & easy.

delete row() dynamically

Hi!

I can add rows with inputs to my HTML table dynamically using DOM, but I cannot remove selected rows. In fact, every row contains a Delete button. So, user selects the rows to remove, clicks the delete button selected row wants to delete.

My problem is(If i delete the first row, its say undefined and change the value is 0) pls check my program.

Expand|Select|Wrap|Line Numbers
  1. <%pathdefiner = "../"%>
  2. <!--#include file="../connection/connector.asp" -->
  3. <!--#include file="declareVariables.asp" -->
  4. <!--#include file="../MainMenu/Header.htm" -->
  5.  
  6.  
  7.  
  8.  
  9. <script language="JavaScript" type="text/javascript">
  10. <!--
  11. var hasLoaded = false;
  12.  
  13. function addRowToTable()
  14. {
  15.   var c=0;
  16. //  var nos=1;
  17. // var i;
  18.  
  19.   var tbl = document.getElementById('tblSample');
  20.   var lastRow = tbl.rows.length;
  21.   // if there's no header row in the table, then iteration = lastRow + 1
  22.   var iteration = lastRow;
  23.   //document.write ("iteration = " + iteration);
  24.  
  25.   if(lastRow == 7)
  26.   {
  27.   alert("Only six countrys");
  28.   }
  29.   else{
  30.   var row = tbl.insertRow(lastRow);
  31.  
  32.   // left cell
  33.   var cellLeft = row.insertCell(0);
  34.   var textNode = document.createTextNode(iteration);
  35.   cellLeft.appendChild(textNode);
  36.  
  37.   // right cell
  38.   var cellRight = row.insertCell(1);
  39.   var el = document.createElement('input');
  40.   el.type = 'text';
  41.   el.name = 'txt_C' + iteration;
  42.   el.id = 'txt_C' + iteration;
  43.   el.size = 40;
  44.  
  45.   el.onkeypress = keyPressTest;
  46.   cellRight.appendChild(el);
  47.  
  48.  
  49.     // text box cell
  50.   var textRight = row.insertCell(2);
  51.   var el = document.createElement('input');
  52.   el.type = 'text';
  53.   el.name = 'txt_F' + iteration;
  54.   el.id = 'txt_F' + iteration;
  55.   el.onfocus = function(event){return showCalendarControl(this);};
  56.   el.size = 20;
  57.   el.onblur = this;
  58.   el.readOnly = this;
  59.  
  60.   el.onkeypress = keyPressTest;
  61.   textRight.appendChild(el);
  62.  
  63.    // text box cell
  64.   var txtRight = row.insertCell(3);
  65.   var el = document.createElement('input');
  66.   el.type = 'text';
  67.   el.name = 'txt_T' + iteration;
  68.   el.id = 'txt_T' + iteration;
  69.   el.onfocus = function(event){return showCalendarControl(this);};
  70.   el.size = 20;
  71.   el.onblur = this;
  72.   el.readOnly = this;
  73.  
  74.   el.onkeypress = keyPressTest;
  75.   txtRight.appendChild(el);
  76.  
  77.       // Delete Button
  78.     var btnRight = row.insertCell(4);
  79.     var  el = document.createElement('input');
  80.     el.type = 'button';
  81.     el.name = 'btnDel' + iteration;
  82.     el.id = 'btnDel' + iteration;
  83.     el.value = 'Delete'
  84.     el.onfocus = function(event){return removeRowFromTable(this);};
  85.     el.onkeypress = keyPressTest;
  86.     btnRight.appendChild(el);
  87.  
  88.  
  89.  
  90.      //Row count
  91.     lastRow = c+lastRow
  92.     document.frm.txt_count.value = lastRow;
  93.  
  94.     }
  95. }
  96.  
  97. function keyPressTest(e, obj)
  98. {
  99.     var displayObj = document.getElementById('spanOutput');
  100.     var key;
  101.     if(window.event) {
  102.       key = window.event.keyCode; 
  103.     }
  104.     else if(e.which) {
  105.       key = e.which;
  106.     }
  107.     var objId;
  108.     if (obj != null) {
  109.       objId = obj.id;
  110.     } else {
  111.       objId = this.id;
  112.     }
  113. }
  114.  
  115.  
  116. function removeRowFromTable(r)
  117. {
  118.   var i=r.parentNode.parentNode.rowIndex;
  119.   var tbl = document.getElementById('tblSample');
  120.   var lastRow = tbl.rows.length;
  121.   alert(i);
  122.  if (lastRow > 2 ) 
  123.   {
  124.   alert("i"+i);
  125.   tbl.deleteRow(i+1);
  126.   }
  127.   else
  128.   {
  129.     alert("Please enter 'NIL' for country if your are not travelling");
  130.     return;
  131. }
  132.  
  133.     var tbl = document.getElementById('tblSample');
  134.     var lastRow = tbl.rows.length - 1;
  135.     document.frm.txt_count.value = lastRow;
  136.  
  137.     //frm.action = "Remove_Data.asp";
  138.     //frm.submit();
  139. }
  140.  
  141. function onloa()
  142. {
  143.     var tbl = document.getElementById('tblSample');
  144.     var lastRow = tbl.rows.length - 1;
  145.     document.frm.txt_count.value = lastRow;
  146.  
  147. }
  148.  
  149. function validateRow(frm)
  150. {
  151.     var tbl = document.getElementById('tblSample');
  152.     var lastRow = tbl.rows.length - 1;
  153.     var i;
  154.     var compDate,j;
  155.  
  156.     for (i=1; i<=lastRow; i++) {
  157.       var aRow = document.getElementById('txt_C' + i);
  158.       var FDate = document.getElementById('txt_F' + i).value;
  159.       var TDate = document.getElementById('txt_T' + i).value;
  160.       var country = document.getElementById('txt_C' + i).value; 
  161.  
  162.       country = country.toUpperCase();    
  163.  
  164.  
  165.       if (aRow.value.length <= 0) {
  166.         alert('The country ' + i + ' is empty');
  167.         return;
  168.       }
  169.       var test;
  170.       test = "NIL" 
  171.       compDate = TDate - FDate;
  172.  
  173.       if (FDate>TDate) {
  174.         alert("You have entered the date incorrectly on Row '" + i +"', please make the necessary amendments.");
  175.         return;
  176.       }    
  177.  
  178.      // else
  179.      if (country != test)
  180.      {
  181.          if(FDate == "NaN" || TDate == "NaN")
  182.         {
  183.         alert("You have entered the date incorrectly on Row '" + i +"', please make the necessary amendments.");
  184.         return;
  185.         }
  186.  
  187.          else if(FDate == "" || TDate == "")
  188.         {
  189.         alert("You have entered the date incorrectly on Row '" + i +"', please make the necessary amendments.");
  190.         return;
  191.         }
  192.     }
  193.  
  194.  
  195. //    else
  196. //    {
  197. //    alert("Please enter the Date" + i);
  198. //    return;
  199. //    }  
  200.  
  201.     }// for loop end
  202.  
  203.     if(document.getElementById('tet_Name_PG').value == "NIL" || document.getElementById('tet_Name_PG').value == "")
  204.     {
  205.     alert("Please enter Name of Parent/Guardian. ");
  206.     return;
  207.     }
  208.  
  209.     var cons;
  210.     cons = document.getElementById('tet_Contact').value;
  211.  
  212.     if (!Number(cons)) 
  213.            { 
  214.           alert('Please enter Parent/Guardian Contact no.') 
  215.    //   frm.tet_Contact.focus(); 
  216.           return; 
  217.       } 
  218.  
  219.  
  220.   frm.submit();
  221. }
  222.  
  223. function Stud_Qual()
  224.  {
  225.  if(document.getElementById("txt_C1").value == "NIL")
  226.     {
  227.       document.getElementById("txt_F1").value = document.getElementById("txt_C1").value;
  228.       document.getElementById("txt_T1").value = document.getElementById("txt_C1").value;
  229.       }
  230.  
  231.  }
  232. function MM_jumpMenu(targ,selObj,restore){ //v3.0
  233.   eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  234.   if (restore) selObj.selectedIndex=0;
  235. }
  236. //-->
  237. </script>
  238. <style type="text/css">
  239. <!--
  240. .style3 {
  241.     font-size: 1px;
  242.     color: #FFFFFF;
  243. }
  244. .style4 {
  245.     font-size: 24px;
  246.     font-weight: bold;
  247.     color: #003333;
  248. }
  249. .style9 {font-size: 18px; font-weight: bold; }
  250. .style10 {color: #EE0000}
  251. -->
  252. </style>
  253.  
  254. <%
  255. Dim retrieveSql, rSql
  256. retrieveSql = "SELECT * FROM "& TBL_LOGIN & " WHERE " & TFL_IC & "='"& Session.Contents("IDNO") &"';"
  257.  
  258. Set rsRetrieve = Server.CreateObject("ADODB.Recordset")
  259. Set rsRetrieve.ActiveConnection = my_Conn
  260.  
  261. rsRetrieve.Source = retrieveSql
  262. rsRetrieve.Open
  263.  
  264.  
  265. if rsRetrieve.EOF Then
  266. else
  267. do until rsRetrieve.EOF    
  268. %>
  269. <form name="frm" id="frm" method="post" action="Update_Data.asp">
  270. <table align="center" width="300" border="2" cellspacing="0" cellpadding="0" bordercolor="#004400" bgcolor="#e5ffe5">
  271.   <tr>
  272.     <td><img src="../images/overseas_travel5.jpg" width="872" height="242"></td>
  273.   </tr>
  274.   <tr>
  275.     <td>
  276.     <p>&nbsp;</p>
  277.     <p align="center" class="style4">INFORMING SCHOOL OF CHILD'S/WARD'S TRAVEL PLANS</p>
  278. <p>&nbsp;</p>
  279.  
  280.         <div align="center">
  281.         <p>&nbsp;</p>
  282.           <select name="travel" id="travel" onChange="javascript:YesOnclick('travel', 'SPAN_travel', 'YES')">
  283.             <option value="NIL">--Choose one--</option>
  284.             <option value="YES"> Travelling </option>
  285.             <option value="NO"> Not_Travelling </option>
  286.           </select>
  287.  
  288.         <p>&nbsp;</p>
  289.         </label></div>
  290.  
  291. <table width="595" align="center" border="0" cellspacing="3" cellpadding="2">
  292.   <tr>
  293.     <td width="189"><span class="style9">Name of Child/Ward</span></td>
  294.     <td width="16"><div align="center">:</div></td>
  295.     <td width="334">&nbsp;<b><% =rsRetrieve("Name")%></b></td>
  296.   </tr>
  297.   <tr>
  298.     <td><span class="style9">NRIC/FIN No.</span></td>
  299.     <td><div align="center">:</div></td>
  300.     <td>&nbsp;<b><%=Session.Contents("IDNO")%></b></td>
  301.   </tr>
  302.   <tr>
  303.     <td><span class="style9">Sex</span></td>
  304.     <td><div align="center">:</div></td>
  305.     <td>&nbsp;<b><% =rsRetrieve("Sex")%></b></td>
  306.   </tr>
  307.   <tr>
  308.     <td>&nbsp;</td>
  309.     <td>&nbsp;</td>
  310.     <td>&nbsp;</td>
  311.   </tr>
  312.   <tr>
  313.     <td colspan="3"><strong>This is to inform the school that my child/ward will be traveling to the following country/countries during the school holidays. The details are as listed below:</strong></td>
  314.     </tr>
  315. </table>
  316. <p class="style10">&nbsp;</p>
  317.  
  318. <table width="583" align="center" height="91" border="0" cellpadding="0" cellspacing="0">
  319.   <tr>
  320.     <td width="583"><p class="style10"><strong>Important Notes:</strong></p>
  321.       <p class="style10"><strong>1. Where possible, please also provide details of country and date of transit if your child/ward will be stopping over at any other country while travelling.</strong></p>
  322.       <p class="style10"><strong>2. If your child/ward will not be traveling, please return the form with a NIL return.</strong></p></td>
  323.   </tr>
  324. </table>
  325. <p class="style10">&nbsp;</p>
  326. <table width="746" align="center" border="0" cellspacing="0" cellpadding="0">
  327.   <tr>
  328.     <td width="746"><p>&nbsp;</p>
  329.     <table width="639" align="center" border="1" cellpadding="3" cellspacing="2">
  330.   <tr>
  331.     <th width="282" rowspan="2" class="style9">Country of Intended Travel</th>
  332.     <th colspan="2" class="style9">Period of Stay</th>
  333.     </tr>
  334.   <tr>
  335.     <th width="151" class="style9">From</th>
  336.     <th width="151" class="style9">To</th>
  337.   </tr>
  338. </table>
  339.  
  340. <table width="665" align="center" border="1" cellpadding="3" cellspacing="2" id="tblSample">
  341. <tr>
  342.     <td colspan="6"><span class="style3">a</span></td>
  343.     </tr>
  344.   <%
  345.  
  346. Dim RetrieveArr(3)
  347.  
  348. coun = rsRetrieve("no_row")
  349.  
  350.             for n = 1 to coun
  351.  
  352.         //for each x in rsRetrieve.fields
  353.         for j = 0 to Ubound(all_fields)-1
  354.             Dim dbname
  355.             dbname = all_fields(j)
  356.             dbname = MID(dbname,5)
  357.  
  358.     dbname = Replace(dbname,1,",")
  359.     dbname = Replace(dbname,",",n)
  360.  
  361.             RetrieveArr(j) = rsRetrieve(dbname)
  362.             //response.write(dbname)&" " & RetrieveArr(j) &"<br>"
  363.               next
  364.   %>
  365.   <%   if rsRetrieve("no_row") = 0 then %>
  366.   <tr>
  367.  
  368.     <td width="12"><b> 1 </b></td> 
  369.   <% else %>
  370.     <td width="17"><%=response.Write (n) %></td>
  371.   <% end if %>
  372.     <td width="255"><input type="text" name="txt_C1" id="txt_C1" size="40" onKeyPress="keyPressTest(event, this);" onBlur="javascript:Stud_Qual();" value="<%=RetrieveArr(0)%>" /></td>
  373.  
  374.     <td width="144"><label>
  375.       <input type="text" name="txt_F1" id="txt_F1" onFocus="javascript:showCalendarControl(this);" value="<%=RetrieveArr(1)%>" readonly  />
  376.     </label></td>
  377.     <td width="146"><label>
  378.       <input type="text" name="txt_T1" id="txt_T1" onFocus="javascript:showCalendarControl(this);" value="<%=RetrieveArr(2)%>" readonly  />
  379.     </label></td>
  380.     <td width="27"><label>
  381.   <input name="btnDel" id="btnDel1" type="button" value="Delete" onClick="javascript:removeRowFromTable(this);">
  382.   </label></td>
  383.   </tr>
  384.   <%
  385.         //next
  386.     //    i=i+1
  387.     //    rsRetrieve.MoveNext
  388.         next
  389.  
  390. //  next
  391.   %>
  392. </table>
  393.  
  394.       <p>&nbsp;</p>
  395.  
  396.       <p align="center">&nbsp;
  397.   <input type="button" value="Add New Row" onClick="addRowToTable();" />
  398. </p>
  399. <p>&nbsp;</p>
  400.       </td>
  401.   </tr>
  402. </table>
  403.  
  404.  
  405.  
  406. <table width="617" align="center" border="0" cellspacing="0" cellpadding="0">
  407.   <tr>
  408.     <td width="251" class="style9">Name of Parent/Guardian</td>
  409.     <td width="32" class="style9"><div align="center">:</div></td>
  410.     <td width="334" class="style9"><label>
  411.     <input type="text" name="tet_Name_PG" id="tet_Name_PG" value="<% =rsRetrieve("Name_PG")%>">
  412.     </label></td>
  413.   </tr>
  414.   <tr>
  415.     <td class="style9">Parent/Guardian contact No.</td>
  416.     <td class="style9"><div align="center">:</div></td>
  417.     <td class="style9"><label>
  418.     <input type="text" name="tet_Contact" id="tet_Contact" value="<% =rsRetrieve("Contact")%>" >
  419.     </label></td>
  420.   </tr>
  421. </table> <p>&nbsp;</p>
  422.   <div align="center">
  423.   <input type="hidden" name="txt_count" id="txt_count"  >
  424.   <input name="btnSave" type="button" value="Submit" onClick="javascript:validateRow(this.form);">
  425.    </div>
  426.   <p>&nbsp;</p>  </td>
  427.   </tr>
  428. </table>
  429.  
  430.  
  431. </form>
  432. <%
  433.      rsRetrieve.MoveNext
  434.      loop
  435.      End if
  436.  rsRetrieve.Close
  437.  my_Conn.Close
  438.  Set rsRetrieve = Nothing
  439.  Set my_Conn = Nothing
  440.  Response.Expires=-1
  441. %>
  442. <!--#include file="../MainMenu/Footer.htm" -->
  443.  
  444. <script>
  445.     setupScript();
  446. </script>
  447.  
  448.  
Pls help me....

Thanks,
Susan.
May 2 '09 #1
29 5011
acoder
16,027 Expert Mod 8TB
You have the following events:
Expand|Select|Wrap|Line Numbers
  1. el.onfocus = function(event){return removeRowFromTable(this);};
  2. el.onkeypress = keyPressTest;
Surely you mean onclick and don't require the keypress event. I haven't checked the remove function(). What line does the error occur on and what is the exact error message?
May 2 '09 #2
Hi!

Expand|Select|Wrap|Line Numbers
  1. function removeRowFromTable(r) 
  2.   var i=r.parentNode.parentNode.rowIndex;  // pls check this line.... 
  3.   var tbl = document.getElementById('tblSample'); 
  4.   var lastRow = tbl.rows.length; 
  5.   alert(i); 
  6.  if (lastRow > 2 )  
  7.   { 
  8.   alert("i"+i); 
  9.   tbl.deleteRow(i+1); 
  10.   } 
  11.   else 
  12.   { 
  13.     alert("Please enter 'NIL' for country if your are not travelling"); 
  14.     return; 
  15.  
  16.     var tbl = document.getElementById('tblSample'); 
  17.     var lastRow = tbl.rows.length - 1; 
  18.     document.frm.txt_count.value = lastRow; 
  19.  
  20.     //frm.action = "Remove_Data.asp"; 
  21.     //frm.submit(); 
If i delete the second row. alert msg say the value is 2, then If i delete the first row, alert msg say undefined value and automatically change the value is 0. why?
The value is changed 0, that time only display error. the error message is "Invalid argument". This is my problem. Pls help me.... Pls reply to me immediately.


Thanks and Regards,
Susan.
May 4 '09 #3
dmjpro
2,476 2GB
Can you show me the generated HTML code.
If there is an external JS link then post it also.
You are having table headers. And you want to delete all the rows except table headers.

Expand|Select|Wrap|Line Numbers
  1. button_ref = function(){removeRow(this.parentNode.parentNode);}
  2. ...
  3. ...
  4.  
  5. function removeRow(row_ref){
  6. row_ref.parentNode.removeChild(row_ref);
  7. }
  8.  
May 4 '09 #4
Hi!

Thankyou very much for reply.

I want to delete seleted rows and except row header. Now i problem is (If i delete the second row. alert msg say the value is 2, delete the forth row. alert msg say the value is 4. and If i delete the first row, alert msg say undefined value and change the value automatically is 0. why?) Kindly help me.... pls check my coding is below:

Expand|Select|Wrap|Line Numbers
  1. function setupScript()
  2.     {
  3.     YesOnclick('travel', 'SPAN_travel', 'YES');
  4.     }
  5.  
  6. function displayNhide(display,status){
  7.     document.getElementById(display).style.display = status;
  8. }
  9.  
  10. function YesOnclick(onClickbtn, spanId, valueToCheck){
  11.     var value = document.getElementById(onClickbtn).value;
  12.             alert(value);
  13.  
  14.     if(value != 'NO' || value != 'NIL'){alert("VAlue" + value);
  15.         if(value == "YES")
  16.         displayNhide(spanId, 'block');
  17.         else 
  18.         displayNhide(spanId, 'none');
  19.     } 
  20.  
  21. }
  22.  
  23.  
Expand|Select|Wrap|Line Numbers
  1. <%pathdefiner = "../"%>
  2. <!--#include file="../connection/connector.asp" -->
  3. <!--#include file="declareVariables.asp" -->
  4. <!--#include file="../MainMenu/Header.htm" -->
  5.  
  6.  
  7.  
  8.  
  9. <script language="JavaScript" type="text/javascript">
  10. <!--
  11. var hasLoaded = false;
  12.  
  13. function addRowToTable()
  14. {
  15.   var c=0;
  16. //  var nos=1;
  17. // var i;
  18.  
  19.   var tbl = document.getElementById('tblSample');
  20.   var lastRow = tbl.rows.length;
  21.   // if there's no header row in the table, then iteration = lastRow + 1
  22.   var iteration = lastRow;
  23.   //document.write ("iteration = " + iteration);
  24.  
  25.   if(lastRow == 7)
  26.   {
  27.   alert("Only six countrys");
  28.   }
  29.   else{
  30.   var row = tbl.insertRow(lastRow);
  31.  
  32.   // left cell
  33.   var cellLeft = row.insertCell(0);
  34.   var textNode = document.createTextNode(iteration);
  35.   cellLeft.appendChild(textNode);
  36.  
  37.   // right cell
  38.   var cellRight = row.insertCell(1);
  39.   var el = document.createElement('input');
  40.   el.type = 'text';
  41.   el.name = 'txt_C' + iteration;
  42.   el.id = 'txt_C' + iteration;
  43.   el.size = 40;
  44.  
  45.   el.onkeypress = keyPressTest;
  46.   cellRight.appendChild(el);
  47.  
  48.  
  49.     // text box cell
  50.   var textRight = row.insertCell(2);
  51.   var el = document.createElement('input');
  52.   el.type = 'text';
  53.   el.name = 'txt_F' + iteration;
  54.   el.id = 'txt_F' + iteration;
  55.   el.onfocus = function(event){return showCalendarControl(this);};
  56.   el.size = 20;
  57.   el.onblur = this;
  58.   el.readOnly = this;
  59.  
  60.   el.onkeypress = keyPressTest;
  61.   textRight.appendChild(el);
  62.  
  63.    // text box cell
  64.   var txtRight = row.insertCell(3);
  65.   var el = document.createElement('input');
  66.   el.type = 'text';
  67.   el.name = 'txt_T' + iteration;
  68.   el.id = 'txt_T' + iteration;
  69.   el.onfocus = function(event){return showCalendarControl(this);};
  70.   el.size = 20;
  71.   el.onblur = this;
  72.   el.readOnly = this;
  73.  
  74.   el.onkeypress = keyPressTest;
  75.   txtRight.appendChild(el);
  76.  
  77.       // Delete Button
  78.     var btnRight = row.insertCell(4);
  79.     var  el = document.createElement('input');
  80.     el.type = 'button';
  81.     el.name = 'btnDel' + iteration;
  82.     el.id = 'btnDel' + iteration;
  83.     el.value = 'Delete'
  84.     el.onfocus = function(event){return removeRowFromTable(this);};
  85.     el.onkeypress = keyPressTest;
  86.     btnRight.appendChild(el);
  87.  
  88.  
  89.  
  90.      //Row count
  91.     lastRow = c+lastRow
  92.     document.frm.txt_count.value = lastRow;
  93.  
  94.     }
  95. }
  96.  
  97. function keyPressTest(e, obj)
  98. {
  99.     var displayObj = document.getElementById('spanOutput');
  100.     var key;
  101.     if(window.event) {
  102.       key = window.event.keyCode; 
  103.     }
  104.     else if(e.which) {
  105.       key = e.which;
  106.     }
  107.     var objId;
  108.     if (obj != null) {
  109.       objId = obj.id;
  110.     } else {
  111.       objId = this.id;
  112.     }
  113. }
  114.  
  115.  
  116. function removeRowFromTable(r)
  117. {
  118.   var i=r.parentNode.parentNode.rowIndex;
  119.   var tbl = document.getElementById('tblSample');
  120.   var lastRow = tbl.rows.length;
  121.   alert(i);
  122.  if (lastRow > 2 ) 
  123.   {
  124.   alert("i"+i);
  125.   tbl.deleteRow(i);
  126.   }
  127.   else
  128.   {
  129.     alert("Please enter 'NIL' for country if your are not travelling");
  130.     return;
  131. }
  132.  
  133.     var tbl = document.getElementById('tblSample');
  134.     var lastRow = tbl.rows.length - 1;
  135.     document.frm.txt_count.value = lastRow;
  136.  
  137.     //frm.action = "Remove_Data.asp";
  138.     //frm.submit();
  139. }
  140.  
  141. function onloa()
  142. {
  143.     var tbl = document.getElementById('tblSample');
  144.     var lastRow = tbl.rows.length - 1;
  145.     document.frm.txt_count.value = lastRow;
  146.  
  147. }
  148.  
  149. function validateRow(frm)
  150. {
  151.     var tbl = document.getElementById('tblSample');
  152.     var lastRow = tbl.rows.length - 1;
  153.     var i;
  154.     var compDate,j;
  155.  
  156.     for (i=1; i<=lastRow; i++) {
  157.       var aRow = document.getElementById('txt_C' + i);
  158.       var FDate = document.getElementById('txt_F' + i).value;
  159.       var TDate = document.getElementById('txt_T' + i).value;
  160.       var country = document.getElementById('txt_C' + i).value; 
  161.  
  162.       country = country.toUpperCase();    
  163.  
  164.  
  165.       if (aRow.value.length <= 0) {
  166.         alert('The country ' + i + ' is empty');
  167.         return;
  168.       }
  169.       var test;
  170.       test = "NIL" 
  171.       compDate = TDate - FDate;
  172.  
  173.       if (FDate>TDate) {
  174.         alert("You have entered the date incorrectly on Row '" + i +"', please make the necessary amendments.");
  175.         return;
  176.       }    
  177.  
  178.      // else
  179.      if (country != test)
  180.      {
  181.          if(FDate == "NaN" || TDate == "NaN")
  182.         {
  183.         alert("You have entered the date incorrectly on Row '" + i +"', please make the necessary amendments.");
  184.         return;
  185.         }
  186.  
  187.          else if(FDate == "" || TDate == "")
  188.         {
  189.         alert("You have entered the date incorrectly on Row '" + i +"', please make the necessary amendments.");
  190.         return;
  191.         }
  192.     }
  193.  
  194.  
  195. //    else
  196. //    {
  197. //    alert("Please enter the Date" + i);
  198. //    return;
  199. //    }  
  200.  
  201.     }// for loop end
  202.  
  203.     if(document.getElementById('tet_Name_PG').value == "NIL" || document.getElementById('tet_Name_PG').value == "")
  204.     {
  205.     alert("Please enter Name of Parent/Guardian. ");
  206.     return;
  207.     }
  208.  
  209.     var cons;
  210.     cons = document.getElementById('tet_Contact').value;
  211.  
  212.     if (!Number(cons)) 
  213.            { 
  214.           alert('Please enter Parent/Guardian Contact no.') 
  215.    //   frm.tet_Contact.focus(); 
  216.           return; 
  217.       } 
  218.  
  219.  
  220.   frm.submit();
  221. }
  222.  
  223. function Stud_Qual()
  224.  {
  225.  if(document.getElementById("txt_C1").value == "NIL")
  226.     {
  227.       document.getElementById("txt_F1").value = document.getElementById("txt_C1").value;
  228.       document.getElementById("txt_T1").value = document.getElementById("txt_C1").value;
  229.       }
  230.  
  231.  }
  232. function MM_jumpMenu(targ,selObj,restore){ //v3.0
  233.   eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  234.   if (restore) selObj.selectedIndex=0;
  235. }
  236. //-->
  237. </script>
  238. <style type="text/css">
  239. <!--
  240. .style3 {
  241.     font-size: 1px;
  242.     color: #FFFFFF;
  243. }
  244. .style4 {
  245.     font-size: 24px;
  246.     font-weight: bold;
  247.     color: #003333;
  248. }
  249. .style9 {font-size: 18px; font-weight: bold; }
  250. .style10 {color: #EE0000}
  251. -->
  252. </style>
  253.  
  254. <%
  255. Dim retrieveSql, rSql
  256. retrieveSql = "SELECT * FROM "& TBL_LOGIN & " WHERE " & TFL_IC & "='"& Session.Contents("IDNO") &"';"
  257.  
  258. Set rsRetrieve = Server.CreateObject("ADODB.Recordset")
  259. Set rsRetrieve.ActiveConnection = my_Conn
  260.  
  261. rsRetrieve.Source = retrieveSql
  262. rsRetrieve.Open
  263.  
  264.  
  265. if rsRetrieve.EOF Then
  266. else
  267. do until rsRetrieve.EOF    
  268. %>
  269. <form name="frm" id="frm" method="post" action="Update_Data.asp">
  270. <table align="center" width="300" border="2" cellspacing="0" cellpadding="0" bordercolor="#004400" bgcolor="#e5ffe5">
  271.   <tr>
  272.     <td><img src="http://bytes.com/topic/javascript/images/overseas_travel5.jpg" width="872" height="242"></td>
  273.   </tr>
  274.   <tr>
  275.     <td>
  276.     <p>&nbsp;</p>
  277.     <p align="center" class="style4">INFORMING SCHOOL OF CHILD'S/WARD'S TRAVEL PLANS</p>
  278. <p>&nbsp;</p>
  279.  
  280.         <div align="center">
  281.         <p>&nbsp;</p>
  282.           <select name="travel" id="travel" onChange="javascript:YesOnclick('travel', 'SPAN_travel', 'YES')">
  283.             <option value="NIL">--Choose one--</option>
  284.             <option value="YES"> Travelling </option>
  285.             <option value="NO"> Not_Travelling </option>
  286.           </select>
  287.  
  288.         <p>&nbsp;</p>
  289.         </label></div>
  290.  
  291. <table width="595" align="center" border="0" cellspacing="3" cellpadding="2">
  292.   <tr>
  293.     <td width="189"><span class="style9">Name of Child/Ward</span></td>
  294.     <td width="16"><div align="center">:</div></td>
  295.     <td width="334">&nbsp;<b><% =rsRetrieve("Name")%></b></td>
  296.   </tr>
  297.   <tr>
  298.     <td><span class="style9">NRIC/FIN No.</span></td>
  299.     <td><div align="center">:</div></td>
  300.     <td>&nbsp;<b><%=Session.Contents("IDNO")%></b></td>
  301.   </tr>
  302.   <tr>
  303.     <td><span class="style9">Sex</span></td>
  304.     <td><div align="center">:</div></td>
  305.     <td>&nbsp;<b><% =rsRetrieve("Sex")%></b></td>
  306.   </tr>
  307.   <tr>
  308.     <td>&nbsp;</td>
  309.     <td>&nbsp;</td>
  310.     <td>&nbsp;</td>
  311.   </tr>
  312.   <tr>
  313.     <td colspan="3"><strong>This is to inform the school that my child/ward will be traveling to the following country/countries during the school holidays. The details are as listed below:</strong></td>
  314.     </tr>
  315. </table>
  316. <p class="style10">&nbsp;</p>
  317.  
  318. <table width="583" align="center" height="91" border="0" cellpadding="0" cellspacing="0">
  319.   <tr>
  320.     <td width="583"><p class="style10"><strong>Important Notes:</strong></p>
  321.       <p class="style10"><strong>1. Where possible, please also provide details of country and date of transit if your child/ward will be stopping over at any other country while travelling.</strong></p>
  322.       <p class="style10"><strong>2. If your child/ward will not be traveling, please return the form with a NIL return.</strong></p></td>
  323.   </tr>
  324. </table>
  325. <p class="style10">&nbsp;</p>
  326. <table width="746" align="center" border="0" cellspacing="0" cellpadding="0">
  327.   <tr>
  328.     <td width="746"><p>&nbsp;</p>
  329.     <table width="639" align="center" border="1" cellpadding="3" cellspacing="2">
  330.   <tr>
  331.     <th width="282" rowspan="2" class="style9">Country of Intended Travel</th>
  332.     <th colspan="2" class="style9">Period of Stay</th>
  333.     </tr>
  334.   <tr>
  335.     <th width="151" class="style9">From</th>
  336.     <th width="151" class="style9">To</th>
  337.   </tr>
  338. </table>
  339.  
  340. <table width="665" align="center" border="1" cellpadding="3" cellspacing="2" id="tblSample">
  341. <tr>
  342.     <td colspan="6"><span class="style3">a</span></td>
  343.     </tr>
  344.   <%
  345.  
  346. Dim RetrieveArr(3)
  347.  
  348. coun = rsRetrieve("no_row")
  349.  
  350.             for n = 1 to coun
  351.  
  352.         //for each x in rsRetrieve.fields
  353.         for j = 0 to Ubound(all_fields)-1
  354.             Dim dbname
  355.             dbname = all_fields(j)
  356.             dbname = MID(dbname,5)
  357.  
  358.     dbname = Replace(dbname,1,",")
  359.     dbname = Replace(dbname,",",n)
  360.  
  361.             RetrieveArr(j) = rsRetrieve(dbname)
  362.             //response.write(dbname)&" " & RetrieveArr(j) &"<br>"
  363.               next
  364.   %>
  365.   <%   if rsRetrieve("no_row") = 0 then %>
  366.   <tr>
  367.  
  368.     <td width="12"><b> 1 </b></td> 
  369.   <% else %>
  370.     <td width="17"><%=response.Write (n) %></td>
  371.   <% end if %>
  372.     <td width="255"><input type="text" name="txt_C1" id="txt_C1" size="40" onKeyPress="keyPressTest(event, this);" onBlur="javascript:Stud_Qual();" value="<%=RetrieveArr(0)%>" /></td>
  373.  
  374.     <td width="144"><label>
  375.       <input type="text" name="txt_F1" id="txt_F1" onFocus="javascript:showCalendarControl(this);" value="<%=RetrieveArr(1)%>" readonly  />
  376.     </label></td>
  377.     <td width="146"><label>
  378.       <input type="text" name="txt_T1" id="txt_T1" onFocus="javascript:showCalendarControl(this);" value="<%=RetrieveArr(2)%>" readonly  />
  379.     </label></td>
  380.     <td width="27"><label>
  381.   <input name="btnDel" id="btnDel1" type="button" value="Delete" onClick="javascript:removeRowFromTable(this);">
  382.   </label></td>
  383.   </tr>
  384.   <%
  385.         //next
  386.     //    i=i+1
  387.     //    rsRetrieve.MoveNext
  388.         next
  389.  
  390. //  next
  391.   %>
  392. </table>
  393.  
  394.       <p>&nbsp;</p>
  395.  
  396.       <p align="center">&nbsp;
  397.   <input type="button" value="Add New Row" onClick="addRowToTable();" />
  398. </p>
  399. <p>&nbsp;</p>
  400.       </td>
  401.   </tr>
  402. </table>
  403.  
  404.  
  405.  
  406. <table width="617" align="center" border="0" cellspacing="0" cellpadding="0">
  407.   <tr>
  408.     <td width="251" class="style9">Name of Parent/Guardian</td>
  409.     <td width="32" class="style9"><div align="center">:</div></td>
  410.     <td width="334" class="style9"><label>
  411.     <input type="text" name="tet_Name_PG" id="tet_Name_PG" value="<% =rsRetrieve("Name_PG")%>">
  412.     </label></td>
  413.   </tr>
  414.   <tr>
  415.     <td class="style9">Parent/Guardian contact No.</td>
  416.     <td class="style9"><div align="center">:</div></td>
  417.     <td class="style9"><label>
  418.     <input type="text" name="tet_Contact" id="tet_Contact" value="<% =rsRetrieve("Contact")%>" >
  419.     </label></td>
  420.   </tr>
  421. </table> <p>&nbsp;</p>
  422.   <div align="center">
  423.   <input type="hidden" name="txt_count" id="txt_count"  >
  424.   <input name="btnSave" type="button" value="Submit" onClick="javascript:validateRow(this.form);">
  425.    </div>
  426.   <p>&nbsp;</p>  </td>
  427.   </tr>
  428. </table>
  429.  
  430.  
  431. </form>
  432. <%
  433.      rsRetrieve.MoveNext
  434.      loop
  435.      End if
  436.  rsRetrieve.Close
  437.  my_Conn.Close
  438.  Set rsRetrieve = Nothing
  439.  Set my_Conn = Nothing
  440.  Response.Expires=-1
  441. %>
  442. <!--#include file="../MainMenu/Footer.htm" -->
  443.  
  444. <script>
  445.     setupScript();
  446. </script>
  447.  
  448.  
Pls reply to me immediately........ help me to solve....

Thanks & Regards,
Susan.
May 4 '09 #5
dmjpro
2,476 2GB
Well do one thing ...

Expand|Select|Wrap|Line Numbers
  1. alert(r.tagName);
  2. alert(r.parentNode.tagName);
  3. alert(r.parentNode.parentNode.tagName);
  4.  
Check all the Tag.
May 4 '09 #6
Hi!

alert(r.tagName); ----- i delete the second row. that time the alert message "INPUT", but delete the 3 row & if i delete the first row... that time the alert message is "INPUT" and delete the row header, didn't delete the first row...

alert(r.parentNode.tagName); ---- i delete the second row. that time the alert message "TD", but delete the 3 row & if i delete the first row... that time the alert message is "LABEL" and delete the row header, didn't delete the first row...

alert(r.parentNode.parentNode.tagName); ---- i delete the second row. that time the alert message "TR", but delete the 3 row & If delete the first row.... that time the alert message is "TD" and delete the row header, didn't delete the first row... why? pls help me...

i am not expert in javascript, so pls help me to solve this problem.

Thanks & Regards,
Susan.
May 6 '09 #7
dmjpro
2,476 2GB
@shivasusan
That's what exactly i expected ;)
so answer is already with you..simply remove the label around the INPUT delete button in the first row.
Please let me know what happens ;)
May 6 '09 #8
Hi!

Thankyou soooooo much.... it is working. i try to solve this more than one week, but today i got the answer with your help............ really thankyou... I am so happy..... thanks for you help immediately....:)
May 6 '09 #9
dmjpro
2,476 2GB
Yeah you welcome ;)
For that we are here ......
May 6 '09 #10
Hi!

I need one more help....

In the table i want to change the sl. no. automatically. How?

because If i delete the 3 row, the sl. no. is display (1,2,4,5,6.) wrongly. i want to display 1,2,3,4,5.

Thanks & Regards,
Susan.
May 6 '09 #11
Hi!

Pls help me....
May 6 '09 #12
dmjpro
2,476 2GB
see .................... suppose you want to delete nth row.
and you have m rows, where (m-1)>=n.

Expand|Select|Wrap|Line Numbers
  1. function remove(...){
  2. //delete the row
  3. for(var i=n;i<m-1;i++){
  4.  var first_cell_ref = ...
  5.  first_cell_ref.innerHTML = i+1;
  6. }
  7. }
  8.  
May 6 '09 #13
Hi!

Yes...

but in my program... i display the serial number in addrow() below my coding, so how i can change. If i change the remove(). its automatically change the serial number. sorry i am not understand....
Expand|Select|Wrap|Line Numbers
  1.   var cellLeft = row.insertCell(0); 
  2.   var textNode = document.createTextNode(iteration); 
  3.   cellLeft.appendChild(textNode); 
  4.  
Expand|Select|Wrap|Line Numbers
  1. function removeRowFromTable(r)
  2. {
  3.   var i=r.parentNode.parentNode.rowIndex;
  4.   var tbl = document.getElementById('tblSample');
  5.   var lastRow = tbl.rows.length;
  6. alert(r.parentNode.tagName); 
  7.  if (lastRow > 2 ) 
  8.   {
  9.   alert("i"+i);
  10.   tbl.deleteRow(i);
  11.   }
  12.   else
  13.   {
  14.     alert("Please enter 'NIL' for country if your are not travelling");
  15.     return;
  16. }
  17.  
  18.     var tbl = document.getElementById('tblSample');
  19.     var lastRow = tbl.rows.length - 1;
  20.     document.frm.txt_count.value = lastRow;
  21.  
  22.     //frm.action = "Remove_Data.asp";
  23.     //frm.submit();
  24. }
Thanks & Regards,
susan.
May 6 '09 #14
dmjpro
2,476 2GB
Try this inside the remove function ...
Expand|Select|Wrap|Line Numbers
  1. for(var k=i;k<lastRow-1;k++){
  2.  tbl.rows[k].cells[0].innerHTML = k+1;
  3. }
  4.  
May 6 '09 #15
Hi!

Thankyou soo much. I got the answer.

But i did little bit change.

Expand|Select|Wrap|Line Numbers
  1. for(var k=i;k<lastRow-1;k++){ 
  2.  tbl.rows[k].cells[0].innerHTML = (k-1)+1; 
  3.  
  4.  
Thanks & Regards,
Susan.
May 7 '09 #16
dmjpro
2,476 2GB
@shivasusan
Oh yeah...... That's right. What does it mean (k-1)+1, it means k.
Let the run time system to do operations as little as possible. Avoid unnecessary operation ;) Glad to see that you did that.
May 7 '09 #17
Hi!

I don't know how to change the other cells name?

for ex:(my table like this)

sl. country from to
1 aaa (txt_c1) 5/4/09 (txt_f1) 5/13/09 (txt_t1) // Now i delete this row.
2 bbb (txt_c2) 5/18/09 (txt_f2) 5/25/09 (txt_t2)
3 ccc (txt_c3) 6/2/09 (txt_f3) 6/15/09 (txt_t3) // now i delete this row.
4 eee (txt_c4) 7/15/09 (txt_f4) 7/25/09 (txt_t4)

Now the text box name is:

1 bbb (txtc_2) 5/18/09 (txt_f2) 5/25/09 (txt_t2) // here i want to change the text box name automatically (txtc_1, txtf_1, txtt_1) how?
2 eee (txtc_4) 7/15/09 (txt_f4) 7/25/09 (txt_t4) // here i want to change the text box name automatically (txtc_2, txt_f2, txt_t2) how?

I got this error in validateRow(). in for loop.... (txt_c+i)

sorry Sir/Madam, i don't know. how to change? pls help me.

Expand|Select|Wrap|Line Numbers
  1. function validateRow(frm)
  2. {
  3.     var tbl = document.getElementById('tblSample');
  4.     var lastRow = tbl.rows.length - 1;
  5.     var i;
  6.     var compDate,j;
  7.  
  8.     for (i=1; i<=lastRow; i++) {
  9.       var aRow = document.getElementById('txt_C' + i);
  10.       var FDate = document.getElementById('txt_F' + i).value;
  11.       var TDate = document.getElementById('txt_T' + i).value;
  12.       var country = document.getElementById('txt_C' + i).value; 
  13.       var fieldvalue = document.getElementById("chk_travel").value;
  14.  
  15.       country = country.toUpperCase();    
  16.  
  17.  
  18.       if (aRow.value.length <= 0) {
  19.         alert('The country ' + i + ' is empty');
  20.         return;
  21.       }
  22.       var test;
  23.       test = "NIL" 
  24.       compDate = TDate - FDate;
  25.  
  26.       if (FDate>TDate) {
  27.         alert("You have entered the date incorrectly on Row '" + i +"', please make the necessary amendments0.");
  28.         return;
  29.       }    
  30.  
  31.  
  32.      // else
  33.      if (country != test)
  34.      {
  35.          if(FDate == "NIL" || TDate == "NIL")
  36.         {
  37.         alert("You have entered the date incorrectly on Row '" + i +"', please make the necessary amendments1.");
  38.         return;
  39.         }
  40.  
  41.          else if(FDate == "" || TDate == "")
  42.         {
  43.         alert("You have entered the date incorrectly on Row '" + i +"', please make the necessary amendments2.");
  44.         return;
  45.         }
  46.     }
  47.  
  48.             if(fieldvalue == "YES" && country == "NIL"){
  49.             alert("Please Enter the country name or If you are not Travel please select Not Travelling.");
  50.             return;
  51.             }
  52.  
  53.  
  54.     }// for loop end
  55.  
  56.  
  57.     if(document.getElementById('tet_Name_PG').value == "NIL" || document.getElementById('tet_Name_PG').value == "")
  58.     {
  59.     alert("Please enter Name of Parent/Guardian. ");
  60.     return;
  61.     }
  62.  
  63.     var alphaExp = /^[a-zA-Z]+$/;
  64.     var pgname = document.getElementById('tet_Name_PG').value;
  65.     if(!pgname.match(alphaExp)){
  66.         alert("Please enter only characters");
  67.         return;
  68.     }
  69.  
  70.  
  71.     var cons;
  72.     cons = document.getElementById('tet_Contact').value;
  73.  
  74.     if (!Number(cons)) 
  75.            { 
  76.           alert('Please enter Parent/Guardian Contact no.') 
  77.    //   frm.tet_Contact.focus(); 
  78.           return; 
  79.       } 
  80.  
  81.             if(fieldvalue == "NIL"){
  82.             alert("Please select Travelling or Not Travelling");
  83.             return;
  84.             }
  85.  
  86.   frm.submit();
  87. }
  88.  
Thank & Regards,
Susan.
May 7 '09 #18
dmjpro
2,476 2GB
First of all why are you changing the name. Having the same name you can retrieve the values easily in server side.

Anyway... Updating the name is quite easy if you can change the serial no.

Expand|Select|Wrap|Line Numbers
  1. for(var i=starting_row_num;i<current_row_nos_after_delete;i++){
  2.  var text_box_ref = .. ;
  3.  text_box_ref.name = 'text'+i;
  4. }
  5.  
May 7 '09 #19
Hi!

Thanks for you reply.

i try, but i am not understand.

i wrote this code in remove function. after delete its automatically change the text box name and id. (because my database field name is c1, f1, t1 to c6, f6, t6, so i want to change the field name c1,c2,c3....) pls help me....

now my doubt is:
1. how i can get the old text box name?
2. how i can change the new name for the text box?
3. i want to change the text box "name" and "id".

Expand|Select|Wrap|Line Numbers
  1.  
  2. for(var k=i;k<lastRow-1;k++){ 
  3.  
  4.  tbl.rows[k].cells[0].innerHTML = (k-1)+1; 
  5.       var aRow = document.getElementById('txt_C' + k);
  6.       var FDate = document.getElementById('txt_F' + k);
  7.       var TDate = document.getElementById('txt_T' + k);
  8.  
  9.       aRow.name = ('txt_C' + k);
  10.       FDate.name = ('txt_F' + k);
  11.       TDate.name = ('txt_T' + k);
  12.  
  13.  
  14.  
  15.  
Thanks & Regards,
Susan.
May 7 '09 #20
dmjpro
2,476 2GB
@shivasusan
What's the problem with this? Do three elements alert you right object reference if you do alert(aRow+'\t'+FDate+'\t'+TDate)?
Why are you accessing those using IDs?
Simply you can go to the fields using rows[rowIndex].cells[cellIndex].childNodes[...].
May 7 '09 #21
Hi!

already i checked using alert. its didn't display anything in alert message. but i got error message. "aRow is null (aRow.name = ('txt_C' + k); " so i thought my coding is wrong and i understand wrongly. so i will ask you. how?

then i don't know any thing in rows[rowIndex].cells[cellIndex].childNodes[....]

pls help me... now what i can do? how i can solve this error? i did any wrong in my coding?

Thanks & Regards,
Susan.
May 7 '09 #22
dmjpro
2,476 2GB
@shivasusan
Try with ...
Expand|Select|Wrap|Line Numbers
  1. var aRow = document.getElementById('txt_C' + (k+1));
  2. var FDate = document.getElementById('txt_F' + (k+1));
  3. var TDate = document.getElementById('txt_T' + (k+1));
  4.  
I think that would work.
May 7 '09 #23
Hi!

sorry, still i didn't got the answer. today i want to finish this part, so pls help me....

the alert message display "null". I don't know, how to solve?

Expand|Select|Wrap|Line Numbers
  1. for(var k=i;k<lastRow-1;k++){ 
  2.  
  3.  var aRow = document.getElementById('txt_C' + (k+1)); 
  4. var FDate = document.getElementById('txt_F' + (k+1)); 
  5. var TDate = document.getElementById('txt_T' + (k+1)); 
  6.  
  7.     tbl.rows[k].cells[0].innerHTML = (k-1)+1;       
  8.     alert(aRow+'\t'+FDate+'\t'+TDate);
  9.  
  10.                 // aRow.name = ('txt_C' + k);
  11.      // FDate.name = ('txt_F' + k);
  12.      // TDate.name = ('txt_T' + k);
  13.  
  14.     //    tbl.rows[k].cells[1].childNodes[1].
  15.  
  16.  

change the sr. no. automatically coding below:
tbl.rows[k].cells[0].innerHTML = (k-1)+1;

how i can change the text box name for country, from and to? where i can place the aRow, FDate and TDate? But i try like this way, it is correct.
tbl.rows[k].cells[1].childNodes[1].

pls help i want to finish today itself. pls...

Thanks & Regards,
Susan.
May 8 '09 #24
Hi!

check the tagname "alert(r.parentNode.tagName); "

How i can check the textbox name?
May 8 '09 #25
dmjpro
2,476 2GB
@shivasusan
It should work, but i wonder why document.getElementById(..) is not working :(
May 8 '09 #26
Hi!

Yes.... its display null. pls give some idea. i want to finished this part today itself. so i feel very tension.
May 8 '09 #27
Hi

Now the alert message is "[object HTMLInputElement] [object HTMLInputElement] [object HTMLInputElement] "

Expand|Select|Wrap|Line Numbers
  1. for(var k=i;k<lastRow-1;k++){ 
  2.  
  3.  var aRow = document.getElementById('txtc' + (k+1)); 
  4.  var FDate = document.getElementById('txtf' + (k+1)); 
  5.  var TDate = document.getElementById('txtt' + (k+1)); 
  6.  
  7.     tbl.rows[k].cells[0].innerHTML = (k-1)+1;       
  8.     alert(aRow+'\t'+FDate+'\t'+TDate);
  9.      // aRow.name = ('txt_C' + k);
  10.      // FDate.name = ('txt_F' + k);
  11.      // TDate.name = ('txt_T' + k);
  12.  
  13.     //alert(tbl.rows[k].cells[1].innerHTML);
  14.  
  15.  
this "alert(tbl.rows[k].cells[1].innerHTML);" --- <input size="40" id="txtc5 name=txtc5" type="Text">

pls give me some idea.

Thanks & Regards,
Susan.
May 8 '09 #28
acoder
16,027 Expert Mod 8TB
@shivasusan
Perhaps that's the problem. The ID is actually "txtc5 name=txtc5", not "txtc5" as you would expect because of the missing quotes.
May 8 '09 #29
dmjpro
2,476 2GB
@acoder
But i think he fixed up this error. Now it alerts HTMLInputEelment.
May 8 '09 #30

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by lixiaoyao | last post: by
2 posts views Thread by Matt | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.