473,396 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 3982
acoder
16,027 Expert Mod 8TB
JavaScript is case-sensitive, so it should be "value", not "Value".
Jan 29 '09 #2

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

Similar topics

1
by: johkar | last post by:
I have a grid. When the focus is put on a cell an input is created with the value being the cell's text. I would like to size the input to the physical width of the text. Ideas? John ...
6
by: Michael Hill | last post by:
I have this code that adds a table row and within the cells I create some input elements. When I go back using javascript the functionaliuty is seeing the form element. Anyone tell why I can see...
1
by: Peter Kirk | last post by:
Hi there I have a form which submits a list of data to a web-application (which then saves to a database). The list consists of four input fields per row. Eg....
1
by: John_H | last post by:
Re: ASP.NET 2.0 I would like suggestions or code examples on how to collect a variable length list of input data (item# & item quantity specifically). I thought that I could accomplish this...
2
by: charles-brewster | last post by:
I'm trying to write a simple JavaScript function which will use a button to copy table cell data into a form input text box as the "value" attribute. The following is intended to test the...
6
by: effendi | last post by:
I have an array for of input names. Input1 , input 2 etc. Can I pass the input names in a loop like document.all.value="xxxx" The problem is document.all cannot be used in Safari/firefox, I...
0
by: hcuellar | last post by:
Hi. Please I need your help for this: After a database query, a table is created with a cell for each information retrieved, and for each record, two buttons, and second one have besides it...
5
by: JohnDriver | last post by:
Hi, I am having a form which has a text box and 3 radio buttons. I am using GET method in Ajax to pass the value. I can pass the value of the textbox fine but how to pass the value of radio...
1
by: gbengston | last post by:
Please look at my example, I have a script that pulls the value of one cell and inserts it into an input box in another cell. My problem is that the source cell is itself an input box so when I pull...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.