<table>
<tr><td>
<input type="text" onkeyup = "yaz ('0')"> <! When I enter text in this input, !>
<input type="text"> <! It will be written in this input !>
<input type="text"> <! It will be written in this input !>
<input type="text"> <! It will be written in this input !>
<input type="text"> <! It will be written in this input !>
</td></tr>
<tr><td>
<input type="text" onkeyup = "yaz ('1')"> <! When I enter text in this input, !>
<input type="text"> <! It will be written in this input !>
<input type="text"> <! It will be written in this input !>
<input type="text"> <! It will be written in this input !>
<input type="text"> <! It will be written in this input !>
</td></tr>
</table>
I wrote this, but it doesn't work as I expected.
Code:
<script type="text/javascript">
function yaz (a) {
var e = document.getElementById('form1');
e = e.getElementsByTagName('tr');
e = e[a].getElementsByTagName('td');
e = e.getElementsByTagName('input');
for(var i = 0; i< e.length; i++) {
e[i].value = e[0].value ;
}
}
</script>
<form id="form1">
<table>
<tr><td>
<input type="text" onkeyup = "yaz ('0')">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
</td></tr>
<tr><td>
<input type="text" onkeyup = "yaz ('1')">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
</td></tr>
</table>
</form>
I found my error.
I changed this row:
e = e.getElementsByTagName('input');
I forget to write [0]
e = e[0].getElementsByTagName('input');
It works, now.

Originally Posted by
fang
Code:
e = e.getElementsByTagName('tr');
e = e[a].getElementsByTagName('td');
e = e[0].getElementsByTagName('input');
or
Code:
e = e.getElementsByTagName('tr');
e = e[a].getElementsByTagName('input');
Bookmarks