Jump to content

Link To Display Text In A Textbox


cyberdie

Recommended Posts

it would best to provide your code attempt so that we can see what you know, and so that you can ask specifically what you need help with based on what you're stuck on. Basically you need to know the basics; variables, function, event handlers, and the most common/basic of DOM methods.

Link to comment
Share on other sites

Ok thanks scientist. This is the basics of what I am trying to do, but as I am new to this I dont know how to copy the content from the table into another table which I would like to be contained within a seperate html page. Also If possible I would like it if the information could be transferred into individual textboxes instead of another table. But if not possible then a table will do. Thanks

<body><div id="JohnsDetails">  <table width="400" border="0" cellspacing="2" cellpadding="2">    <caption align="top">	  Johns Details    </caption>    <tr>	  <th width="205" class="style1" scope="col"><div align="center">Description</div></th>	  <th width="181" class="style1" scope="col">Likes</th>    </tr>    <tr>	  <td class="style1"><div align="center">11</div></td>	  <td class="style1"><div align="center">Stamps</div></td>    </tr>    <tr>	  <td class="style1"><div align="center">Tall</div></td>	  <td class="style1"><div align="center">Photos</div></td>    </tr>    <tr>	  <td class="style1"><div align="center">GCSE</div></td>	  <td class="style1"><div align="center">Computers</div></td>    </tr>    <tr>	  <td class="style1"><div align="center">Football</div></td>	  <td class="style1"><div align="center"></div></td>    </tr>  </table></div><div class="style1" id="JohnDisplayed">  <table width="400" border="0" cellspacing="2" cellpadding="2">    <caption align="top">	  John Displayed    </caption>    <tr>	  <th scope="col"> </th>	  <th scope="col"> </th>    </tr>    <tr>	  <td> </td>	  <td> </td>    </tr>    <tr>	  <td> </td>	  <td> </td>    </tr>    <tr>	  <td> </td>	  <td> </td>    </tr>  </table></div><button class="style1" onclick="document.getElementById('JohnDisplayed').value=document.getElementById('JohnsDetails').value">Load Details</button></body></html>

Link to comment
Share on other sites

I'm not sure what you are asking

This is the basics of what I am trying to do, but as I am new to this I dont know how to copy the content from the table into another table
When you are dealing with anything but <input> elements, you need use innerHTML, not value.
<button class="style1" onclick="document.getElementById('JohnDisplayed').innerHTML=document.getElementById('JohnsDetails').innerHTML">Load Details</button>

which I would like to be contained within a seperate html page.
Not sure what that means. Are you trying to save this information? Do you need it to exist for longer than the time the user is on the page?
Also If possible I would like it if the information could be transferred into individual textboxes instead of another table. But if not possible then a table will do.
To do that, you would want to get reference to every element that has a value that you want from the table, and get a reference to an appropriate textbox element that you want to put it's value in. At this point you will want to write a function to do this as opposed to writing the code inline; ideally in an external document or at the end of your HTML markup. If you haven't, I would suggest you read over the tutorials.http://www.w3schools.com/js/default.asp
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...