උදවුවක්

Sea1men

Well-known member
  • Oct 25, 2015
    889
    413
    63
    හදේ
    මචන්ලා මට ඕන මෙන්න මේ වගේ දෙයක් කර ගන්න.
    .
    .
    .


    මගේ jsp එකේ combo box එකක් click කරාම ඒ value එකට අදාලව pack කියලා තියෙන lable එකේ name එක වෙනස් වෙනවා.

    මට ඕන ඒ වෙනස් වෙච්ච නමට අදාලව (ඒ නමට තියෙන id එකට අනුව) තියෙන data ටික තව combo box එකකට load කර ගන්න.

    මේක javascript වලින් කර ගන්න විදියක් දන්නවන් නම් පොඩ්ඩක් කියන්න පුළුවන්ද? :baffled:
     
    • Like
    Reactions: Geshi95

    Error365!

    Well-known member
  • Jun 27, 2012
    12,853
    9,244
    113
    එක තැනක නෑ


    umbe combo box eke onchange event ekedi call karanna me JavaScript method eka machan.


    Code:
    onchange="getData(this.value);"

    habai e combo box eke value eka wenna one umba data search karanna ganna key eka.

    umbata meken idea ekak ganna pulwuan wei. awulak awoth kiyanna machan :)


    Code:
    function getData(myval){
        $.get('API HERE', { // change to your API/Controller or Servlet URL
            parameterkey: myval // change parameterkey to your parameter name
        }, function(response) {
            var select = document.getElementById("target_combo"); // change 'target_combo' to your combo box id
            var json = $.parseJSON(response);
            $.each(json, function() {
                $("#target_combo").append('<option value=' + this['your_json_key_as_value'] + '>' + this['your_json_key_as_data'] +'</option>');
            });
        });
    }
     
    Last edited:
    • Like
    Reactions: Sea1men

    KingCM

    Well-known member
  • Jul 23, 2013
    6,920
    948
    113
    www.biogen.lk
    ඔයාගේ combo box එකට කොහෙන් හරි db එකකින් data එනවනේ....ඒ දට combo එකට load කරනකොට id එකත් එත් එක්කම hidden textfield එකකට load කරන්න....

    ඊට පස්සේ combo එකේ click කරම onchange event එකක් ලියන්න....එකේ id value එක ගන්න...

    ඒ id value එක උබට කැමති විදියකට pass කරලා....එකට අදාල data ටික අයෙත් load කරන්න....

    sequence එකක් යන්නේ....
     

    Sea1men

    Well-known member
  • Oct 25, 2015
    889
    413
    63
    හදේ


    umbe combo box eke onchange event ekedi call karanna me JavaScript method eka machan.


    Code:
    onchange="getData(this.value);"

    habai e combo box eke value eka wenna one umba data search karanna ganna key eka.

    umbata meken idea ekak ganna pulwuan wei. awulak awoth kiyanna machan :)


    Code:
    function getData(myval){
        $.get('API HERE', { // change to your API/Controller or Servlet URL
            parameterkey: myval // change parameterkey to your parameter name
        }, function(response) {
            var select = document.getElementById("target_combo"); // change 'target_combo' to your combo box id
            var json = $.parseJSON(response);
            $.each(json, function() {
                $("#target_combo").append('<option value=' + this['your_json_key_as_value'] + '>' + this['your_json_key_as_data'] +'</option>');
            });
        });
    }

    ඔයාගේ combo box එකට කොහෙන් හරි db එකකින් data එනවනේ....ඒ දට combo එකට load කරනකොට id එකත් එත් එක්කම hidden textfield එකකට load කරන්න....

    ඊට පස්සේ combo එකේ click කරම onchange event එකක් ලියන්න....එකේ id value එක ගන්න...

    ඒ id value එක උබට කැමති විදියකට pass කරලා....එකට අදාල data ටික අයෙත් load කරන්න....

    sequence එකක් යන්නේ....


    මෙන්න යාළුවො
    :love::love::love::love: