943,600 Members | Top Members by Rank

Ad:
Jun 3rd, 2009
0

Javascript- How to load cell values to a form???

Expand Post »
hi, I'm trying to load cell values from a table, to a form in Javascript.... I can caught the cell values but I can't load them to a form....
this is how I caught the cell values:

html Syntax (Toggle Plain Text)
  1. <td id='cellText' >writing the text </td>
  2.  
  3. <script>
  4. alert(document.getElementById('cellText').innerHTML);
  5. </script>

Thank everyone.....
Last edited by peter_budo; Jun 4th, 2009 at 9:44 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Enrico! is offline Offline
5 posts
since Jun 2009
Jun 4th, 2009
0

Re: Javascript- How to load cell values to a form???

you do a similar process to the form, get the form id, then the input field and then do
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. .value=document.getElementById('cellText').innerHTML
Reputation Points: 85
Solved Threads: 64
Practically a Master Poster
sillyboy is offline Offline
686 posts
since Mar 2007
Jun 4th, 2009
0

Re: Javascript- How to load cell values to a form???

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4.  
  5. function getvalue()
  6. {
  7.  
  8. one=document.getElementById("cellone").innerHTML
  9. document.getElementById("box1").value=one;
  10.  
  11. }
  12.  
  13. </script>
  14.  
  15. <body>
  16. <form id="form1">
  17. <table >
  18. <tr>
  19. <td id="cellone">hello</td>
  20. </td>
  21. </tr>
  22.  
  23. </table>
  24.  
  25. <input type="text" id="box1" onclick="getvalue();">
  26.  
  27. </body>
  28. </form>
  29. </html>


with this you can capture the value on clicking on the text box..
you could change the event according to what suits you..

hope it helps..
Reputation Points: 10
Solved Threads: 9
Junior Poster
aashishn86 is offline Offline
184 posts
since Jun 2008
Jun 4th, 2009
1

Re: Javascript- How to load cell values to a form???

Enrico,

As already said, plus it can be proceduralised in a loop as follows:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html>
  4. <head>
  5. <title>Airshow :: Untitled</title>
  6. <script>
  7. onload = function(){
  8. for (var i=1; i<=3; i++) {
  9. var field = document.getElementById('ip_'+i);
  10. if(field) {
  11. field.value = document.getElementById('cellText'+i).innerHTML;
  12. }
  13. }
  14. }
  15. </script>
  16. </head>
  17. <body>
  18. <table border>
  19. <tr><td id='cellText1' >Text 1</td></tr>
  20. <tr><td id='cellText2' >Text 2</td></tr>
  21. <tr><td id='cellText3' >Text 3</td></tr>
  22. </table>
  23. <form>
  24. <input id="ip_1" /><br>
  25. <input id="ip_2" /><br>
  26. <input id="ip_3" /><br>
  27. </form>
  28. </body>
  29. </html>
Airshow
Last edited by Airshow; Jun 4th, 2009 at 8:46 am.
Sponsor
Reputation Points: 300
Solved Threads: 357
WiFi Lounge Lizard
Airshow is offline Offline
2,523 posts
since Apr 2009
Jun 4th, 2009
0

Re: Javascript- How to load cell values to a form???

that's even better............
Reputation Points: 10
Solved Threads: 9
Junior Poster
aashishn86 is offline Offline
184 posts
since Jun 2008
Jun 4th, 2009
0

Re: Javascript- How to load cell values to a form???

Thanks evryone this really great.... I found waht I was looking for.....
Arigato fiends.....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Enrico! is offline Offline
5 posts
since Jun 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Problem in Mozilla Browsers
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Multiple script tags?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC