469,275 Members | 1,287 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Pass the Input text value in a TD cell using DOM

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
1 3755
acoder
16,027 Expert Mod 8TB
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.

Similar topics

6 posts views Thread by Michael Hill | last post: by
1 post views Thread by Peter Kirk | last post: by
2 posts views Thread by charles-brewster | last post: by
6 posts views Thread by effendi | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.