SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    e[i].value = e[0].value ;

    <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.

    Quote 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');
    Last edited by muazzez; Jan 21, 2007 at 04:14.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •