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

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Jun 2009
Posts: 5
Reputation: Enrico! is an unknown quantity at this point 
Solved Threads: 0
Enrico! Enrico! is offline Offline
Newbie Poster

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

 
0
  #1
Jun 3rd, 2009
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:

  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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 686
Reputation: sillyboy is on a distinguished road 
Solved Threads: 61
sillyboy's Avatar
sillyboy sillyboy is offline Offline
Practically a Master Poster

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

 
0
  #2
Jun 4th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 185
Reputation: aashishn86 is an unknown quantity at this point 
Solved Threads: 9
aashishn86's Avatar
aashishn86 aashishn86 is offline Offline
Junior Poster

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

 
0
  #3
Jun 4th, 2009
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..
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 878
Reputation: Airshow will become famous soon enough Airshow will become famous soon enough 
Solved Threads: 124
Airshow's Avatar
Airshow Airshow is offline Offline
Practically a Posting Shark

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

 
1
  #4
Jun 4th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 185
Reputation: aashishn86 is an unknown quantity at this point 
Solved Threads: 9
aashishn86's Avatar
aashishn86 aashishn86 is offline Offline
Junior Poster

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

 
0
  #5
Jun 4th, 2009
that's even better............
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 5
Reputation: Enrico! is an unknown quantity at this point 
Solved Threads: 0
Enrico! Enrico! is offline Offline
Newbie Poster

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

 
0
  #6
Jun 4th, 2009
Thanks evryone this really great.... I found waht I was looking for.....
Arigato fiends.....
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC