• 23-12-2015, 19:27:53
    #1
    arkadaşlar elimde bir kod var ve tabloya göre sabitlenmemiş yani sayfada 2 tablo olduğunda çalışmıyor bunu nasıl çözebilirim.



    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
    </head>
    
    <script type="text/javascript">
    var container = '<tr><td><input type="text" class="plaka left"></td><td><input type="text" class="plaka right" value="#"></td><td><select><option selected></option><option>Palet</option><option>Adet</option></select></td></tr>';
    
    $(document).ready(function() {
    
        function removeEvent() {
            $(".remove").parent().remove(), $("table tr").length > 1 && $("table tr:last").append('<td><span class="remove">SİL</span></td>')
        }
    
        $(document).on("focusout", ".plaka.right", function() {
            var thisValue = Number($(this).parent().prev().find("input").val()),
                eValue = Number($(this).val());
            thisValue >= eValue && "#" != eValue && ($(this).val(Number(thisValue) + 1), $("tr").eq($(this).parent().parent().index() + 1).find(".left").val(Number(thisValue) + 2), removeEvent())
        });
    
        $(document).on("keyup", ".plaka.right", function() {
            var eValue = Number($(this).val().split(" ").join(""));
            eValue >= 0 && $(this).parent().parent().index() == $("tr").length - 1 ? ($("table").append(container), $("table .plaka.left:last").val(Number(eValue) + 1), removeEvent()) : $("tr").eq($(this).parent().parent().index() + 1).find(".left").val(Number( eValue ) + 1)
        });
    
        $(document).on("keyup", ".plaka.left", function() {
            var thisValue = Number($(this).val().split(" ").join(""));
            thisValue > 0 && $("tr").eq( $(this).parent().parent().index() - 1 ).find(".right").val( Number(thisValue) - 1 )
        });
    
        $(document).on("keypress", ".plaka", function(t) {
            var e = t.which ? t.which : t.keyCode;
            return !(e > 31 && (48 > e || e > 57))
        });
    
        $(document).on("click", ".remove", function() {
            $(this).parent().parent().remove();
            removeEvent();
            $("table .plaka.right:last").val("#");
        });
    
    });
    </script>
    
    <style type="text/css">
        .plaka{width: 35px;}
        .remove{ cursor: pointer; }
        #container{display: none;}
    </style>
    
    <body>
        <table>
            <tr>
                <td><input type="text" class="plaka left" value="0" readonly></td>
                <td><input type="text" class="plaka right" value="#"></td>
                <td>
                    <select>
                        <option selected></option>
                        <option>Palet</option>
                        <option>Adet</option>
                    </select>
                </td>
            </tr>
        </table>
    </body>
    </html>
  • 24-12-2015, 13:37:15
    #2
    İki tablo olduğunda, ikisinde de çalışmasını mı istiyorsunuz?

    Probleminizi daha net ve anlaşılabilir bir şekilde anlatırsanız yardımcı olmaya çalışalım.