• 01-10-2021, 00:11:11
    #1
    Mysql veritabanından PHP ile verileri select saydırıyorum burda bir sıkıntı yok, benim yapmak istediğim Select ile her hangi bir ilan türünü seçip, bu ilan türüne ait form elemanlarının input text ve checkboxlar, option, ları seçip ve işaretlediğimi varsayalım, ama ben bu ilan türünden vazgeçip başka ilan türünü seçtiğimde, daha önce seçtiğim ilan türüne ait form elemanlarının değerlerini nasıl sıfırlarım, aşağıdaki kod ile daha önce yapmıştım ama şimdi kod yapısı çalışmadı, bu konuda yardımlarınızı bekliyorum.

    <script type="text/javascript">
    $(document).ready(function() {
    $.divliste = {
    '0' : $([]),
    '1' : $('#1'),
    '2' : $('#2'),
    '3' : $('#3'),
    '4' : $('#4'),
    '5' : $('#5'),
    '6' : $('#6')
    };
    
    $('.divsecici').change(function() {
    // hide all
    $.each($.divliste, function() { this.hide(); });
    // show current
    $.divliste[$(this).val()].show();
    
    //classı selsts olan selectleri seçilmemiş yapıyoruz div değiştiğinde
    $('#1 option, #2 option, #3 option, #4 option, #5 option, #6 option').attr('selected',false);
    $('#1 input[type="checkbox"], #2 input[type="checkbox"], #3 input[type="checkbox"], #4 input[type="checkbox"], #5 input[type="checkbox"], #6 input[type="checkbox"]').attr('checked', false);
    $('#1 input[type="text"], #2 input[type="text"], #3 input[type="text"], #4 input[type="text"], #5 input[type="text"], #6 input[type="text"]').val('');
    });
    });
    </script>
  • 05-10-2021, 23:21:37
    #2
    Arkadaşlar bu konuda yardım edebilecek kimse yokmu
  • 05-10-2021, 23:43:10
    #3
    attr yerine prop dene yada her ikisinide dene

    //classı selsts olan selectleri seçilmemiş yapıyoruz div değiştiğinde
    $('#1 option, #2 option, #3 option, #4 option, #5 option, #6 option').prop('selected',false);
    $('#1 option, #2 option, #3 option, #4 option, #5 option, #6 option').attr('selected',false);
    $('#1 input[type="checkbox"], #2 input[type="checkbox"], #3 input[type="checkbox"], #4 input[type="checkbox"], #5 input[type="checkbox"], #6 input[type="checkbox"]').prop('checked', false);
    $('#1 input[type="checkbox"], #2 input[type="checkbox"], #3 input[type="checkbox"], #4 input[type="checkbox"], #5 input[type="checkbox"], #6 input[type="checkbox"]').attr('checked', false);
    $('#1 input[type="text"], #2 input[type="text"], #3 input[type="text"], #4 input[type="text"], #5 input[type="text"], #6 input[type="text"]').val('');
    });
    });
  • 06-10-2021, 21:47:38
    #4
    ilgice adlı üyeden alıntı: mesajı görüntüle
    attr yerine prop dene yada her ikisinide dene

    //classı selsts olan selectleri seçilmemiş yapıyoruz div değiştiğinde
    $('#1 option, #2 option, #3 option, #4 option, #5 option, #6 option').prop('selected',false);
    $('#1 option, #2 option, #3 option, #4 option, #5 option, #6 option').attr('selected',false);
    $('#1 input[type="checkbox"], #2 input[type="checkbox"], #3 input[type="checkbox"], #4 input[type="checkbox"], #5 input[type="checkbox"], #6 input[type="checkbox"]').prop('checked', false);
    $('#1 input[type="checkbox"], #2 input[type="checkbox"], #3 input[type="checkbox"], #4 input[type="checkbox"], #5 input[type="checkbox"], #6 input[type="checkbox"]').attr('checked', false);
    $('#1 input[type="text"], #2 input[type="text"], #3 input[type="text"], #4 input[type="text"], #5 input[type="text"], #6 input[type="text"]').val('');
    });
    });

    Merhaba Hocam
    veritabanına verileri kayıt etmem için Select option ve inputlara herbirine ayrı ayrı id vermek kod kalabalığı yapmak bana mantıksız geldi,
    Hocam daha önce bulduğum bir kod örneğinde select optin ile çağırdığım diğer form elemanlarını bir örneğini atayım Hocam, bu örnekte Select option ile seçtiğim değerleri ekrana çağırıyorum ama bu örnekte mesela Arsa ya ait değerleri çağırdığımda ekrana yazdırıyor, ekrana gelen Select option, input text, input checkbox ları işaretliyorum buraya kadar her hangi bir sıkıntı yok, ama ben bu Arsa kategorisinde vazgeçip Daire kategorisini seçtiğimde Daireye ait değerler ekrana geliyor ama buradaki hata Arsa ya ait değerler alt yapıda işaretlediğim şekilde kalıyor, benim yapmak istediğim hangi kategoriyi seçtim ise o kategoriye ait değerleri alt yapıda kalması o kategoriye ait verileri veritabanına kayıt etmesini istiyorum, daha önce seçtiğim kategoriye ait değerlerin silinmesi istiyorum,

    tumunuGizle();
    gizlegoster();
    $("body").on("change","select[name=turid]", function(button){
        gizlegoster()
    });
  • 06-10-2021, 22:02:09
    #5
    $('.divsecici').change(function() {
    $(':input','#formID').not(':button, :submit, :reset, :hidden').val('').removeAttr('checked').removeAttr('selected');
    });
  • 06-10-2021, 22:14:20
    #6
    aSSembLy adlı üyeden alıntı: mesajı görüntüle
    $('.divsecici').change(function() {
    $(':input','#formID').not(':button, :submit, :reset, :hidden').val('').removeAttr('checked').removeAttr('selected');
    });
    Merhaba aSSembLy Hocam
    az önce verdiğim kodlama yapısında nasıl yapabiliriz, reset olayını Hocam, kodlama yapısını az önce ki kod yapısına göre uyarlamıştım hocam
  • 06-10-2021, 22:21:15
    #7
    $("body").on("change","select[name=turid]", function(button){
    $(':input','#formID').not(':button, :submit, :reset, :hidden').val('').removeAttr('checked').removeAttr('selected');
    gizlegoster()
    });
    alt bölümü bu şkilde değiştir.

    #formID'i de kendi form ID'inle değiştir.
  • 06-10-2021, 22:37:33
    #8
    aSSembLy adlı üyeden alıntı: mesajı görüntüle
    $("body").on("change","select[name=turid]", function(button){
    $(':input','#formID').not(':button, :submit, :reset, :hidden').val('').removeAttr('checked').removeAttr('selected');
    gizlegoster()
    });
    alt bölümü bu şkilde değiştir.

    #formID'i de kendi form ID'inle değiştir.
    Hocam dediğin gibi yaptım, kategori seçimi yapamıyorum, kategori seçiminde önceki seçtiklerimide reset atıyor
  • 06-10-2021, 22:46:39
    #9
    not() un içerisinde kategori seçimi yaptığın selectin idsini ekle

    not(':button, :submit, :reset, :hidden, #selectID') şeklinde

    yada şöyle söyliyeyim. sıfırlanmasını istemediğin tüm elemanlara sifirlama diye bir class ekle

    not(':button, :submit, :reset, :hidden, .sifirlama') içinide bu şekilde düzenle