By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,871 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,871 IT Pros & Developers. It's quick & easy.

Pass the Input text value in a TD cell using DOM

P: 5
hello , I need to alert the value entered in the text box,which is in TD cell, using DOM
can any one tell how please
here is the code with out a text box which is working
Expand|Select|Wrap|Line Numbers
  1. <html> 
  2. <head> 
  3. <script type="text/javascript"> 
  4. function cell() 
  5. var x=document.getElementById('myTable').rows[0].cells; 
  6. alert(x[0].innerHTML); 
  7. </script> 
  8. </head> 
  9. <body> 
  10. <table id="myTable" border="1"> 
  11. <tr> 
  12. <td>cell 1</td> 
  13. <td>cell 2</td> 
  14. </tr> 
  15. <tr> 
  16. <td>cell 3</td> 
  17. <td>cell 4</td> 
  18. </tr> 
  19. </table> 
  20. <br /> 
  21. <input type="button" onclick="cell()" value="Alert first cell"> 
  22. </body> 
  23. </html>
here is what i need
Expand|Select|Wrap|Line Numbers
  1. <html> 
  2. <head> 
  3. <script type="text/javascript"> 
  4. function cell() 
  5. var x=document.getElementById('myTable').rows[0].cells; 
  6. alert(x[1].firstChild.Value); 
  7. </script> 
  8. </head> 
  9. <body> 
  10. <table id="myTable" border="1"> 
  11. <tr> 
  12. <td>cell 1</td> 
  13. <td><input type="text" id="txt"></td> 
  14. </tr> 
  15. <tr> 
  16. <td>cell 3</td> 
  17. <td>cell 4</td> 
  18. </tr> 
  19. </table> 
  20. <br /> 
  21. <input type="button" onclick="cell()" value="Alert first cell"> 
  22. </body> 
  23. </html>
but i can't see the output if anything wromg please tell me
thanks
Swetha
Jan 29 '09 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
JavaScript is case-sensitive, so it should be "value", not "Value".
Jan 29 '09 #2

Post your reply

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