• 30-11-2015, 17:29:09
    #1
    ucret_1
    ucret_2
    ucret_3
    ucret_4
    ucret_5

    şeklinde text field lerim var.

    toplam_ucret şeklindede textfield im var.

    bunlara fiyat girildiginde toplam ücreti sizce nasıl gösterebilirim.
  • 30-11-2015, 20:29:52
    #2
    javascripte sormuşsunuz ama jquery kullandığınızı umarak ile şöyle hızlı halledebilirsiniz.
    <div class="toplanacaklar">
    <input type="text" >
        <input type="text" >
            <input type="text" >
                <input type="text" >
                    <input type="text" >
                        </div>
    
                        <input type="text" class="toplam">
    $(function(){
       $(".toplanacaklar input").change(function(){
        var t=0;
           $(".toplanacaklar input").each(function(){
             if($(this).val() != "") t = parseFloat($(this).val())+t;
          });
           $(".toplam").val(t);
       });
    });

    html yapınızı paylaşmadığınız için ana mantığı bu örnekle anlarsınız umarım.

    Kolaylıklar.
  • 06-12-2015, 21:54:02
    #3
    bluexpres adlı üyeden alıntı: mesajı görüntüle
    javascripte sormuşsunuz ama jquery kullandığınızı umarak ile şöyle hızlı halledebilirsiniz.
    <div class="toplanacaklar">
    <input type="text" >
        <input type="text" >
            <input type="text" >
                <input type="text" >
                    <input type="text" >
                        </div>
    
                        <input type="text" class="toplam">
    $(function(){
       $(".toplanacaklar input").change(function(){
        var t=0;
           $(".toplanacaklar input").each(function(){
             if($(this).val() != "") t = parseFloat($(this).val())+t;
          });
           $(".toplam").val(t);
       });
    });

    html yapınızı paylaşmadığınız için ana mantığı bu örnekle anlarsınız umarım.

    Kolaylıklar.

    HTML si şu şeklinde:

    <input type="text" name="ucret_1" id="ucret_1" />
    <input type="text" name="ucret_2" id="ucret_2" />
    <input type="text" name="ucret_3" id="ucret_3" />
    <input type="text" name="ucret_4" id="ucret_4" />
    <input type="text" name="ucret_5" id="ucret_5" />
    <br  />
    Toplam
    <input type="text" name="toplam_ucret" id="toplam_ucret" />
  • 06-12-2015, 22:09:11
    #4
    o zaman html'inizi şu şekilde değiştirin.

    <div class="toplanacaklar">
    <input type="text" name="ucret_1" id="ucret_1" />
    <input type="text" name="ucret_2" id="ucret_2" />
    <input type="text" name="ucret_3" id="ucret_3" />
    <input type="text" name="ucret_4" id="ucret_4" />
    <input type="text" name="ucret_5" id="ucret_5" />
    <br  /></div>
    Toplam
    <input type="text" class="toplam" name="toplam_ucret" id="toplam_ucret" />
    kolaylıklar.

    nurettin adlı üyeden alıntı: mesajı görüntüle
    HTML si şu şeklinde:

    <input type="text" name="ucret_1" id="ucret_1" />
    <input type="text" name="ucret_2" id="ucret_2" />
    <input type="text" name="ucret_3" id="ucret_3" />
    <input type="text" name="ucret_4" id="ucret_4" />
    <input type="text" name="ucret_5" id="ucret_5" />
    <br  />
    Toplam
    <input type="text" name="toplam_ucret" id="toplam_ucret" />