Client Script Onload Event

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
lissa
User
Posts: 19

Client Script Onload Event

Post by lissa »

hi can anyone help me,
My code successfully runs in client script->add/copy page->startup script.
but I put it on the edit page and I changed the event to onload and it didn't work.
I just changed the "change" event to "load"

this is the code:

$(document).ready(function(){
     $("#r_id_mob").hide();
     $("#r_km_st").hide();
     $("#r_km_en").hide();
     $("#r_km_tot").hide();
     $("#x_pak_mob").on("load", function() {
         var str = $("option:selected", this);
         if (this.value == "1") {
             $("#r_id_mob").hide();
             $("#r_km_st").hide();
             $("#r_km_en").hide();
             $("#r_km_tot").hide();
         } else {
             $("#r_id_mob").show();
             $("#r_km_st").show();
             $("#r_km_en").show();
             $("#r_km_tot").hide();
         }
     });
});

arbei
User
Posts: 9384

Post by arbei »

  1. Selection list are Select2 widget, there is no "load" event, see Events.
  2. Selection list options are loaded by Ajax, you need to wait until they are loaded, you may search "updatedone" in the docs or in this forum.
  3. You better use Client side events (for Add/Copy/Edit/Search).

Post Reply