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:

<td id='cellText' >writing the text </td> 

<script>
alert(document.getElementById('cellText').innerHTML);
</script>

Thank everyone.....

you do a similar process to the form, get the form id, then the input field and then do

.value=document.getElementById('cellText').innerHTML
<html>
<head>
<script type="text/javascript">

function getvalue()
 {
 
  one=document.getElementById("cellone").innerHTML 
  document.getElementById("box1").value=one;

 }

</script>

<body>
<form id="form1">
<table >
<tr>
<td id="cellone">hello</td>
</td>
</tr>

</table>

<input type="text" id="box1" onclick="getvalue();">

</body>
</form>
</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..

Enrico,

As already said, plus it can be proceduralised in a loop as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Airshow :: Untitled</title>
<script>
onload = function(){
	for (var i=1; i<=3; i++) {
		var field = document.getElementById('ip_'+i);
		if(field) {
			field.value = document.getElementById('cellText'+i).innerHTML;
		}
	}
}
</script>
</head>
<body>
<table border>
<tr><td id='cellText1' >Text 1</td></tr>
<tr><td id='cellText2' >Text 2</td></tr>
<tr><td id='cellText3' >Text 3</td></tr>
</table> 
<form>
<input id="ip_1" /><br>
<input id="ip_2" /><br>
<input id="ip_3" /><br>
</form>
</body>
</html>

Airshow

Comments
thats a better way of doing it...

Thanks evryone this really great.... I found waht I was looking for.....
Arigato fiends.....

This article has been dead for over six months. Start a new discussion instead.