How to change the text of field description based on dropdown list selection

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
ayussuf
Veteran Member
Posts: 39
Joined: 2021-01-20 17:15

How to change the text of field description based on dropdown list selection

Post by ayussuf » 2021-02-25 10:49

Hello,

I'am trying to change the text of field description in detail view based on the selection of user in dropdown list. I've make some jquery code and put it on tablename-dv.js. Unfortunately it doesn't work.

But if I put the code in console, it work. But if I change another dropdown list, it fail to work again.

What is the problem. Can somebody help?

Thank you

This is the code:

Code: Select all

$j(function () {
    $j('#s2id_bidang-container > a > span').on('DOMSubtreeModified',function(){
        if ($j(this).text() == 'KanBA' || $j(this).text() == 'KanPIPQ') {
            $j('#perancangan-description > div').text('A. KANDUNGAN (ASPEK PERANCANGAN PEMBELAJARAN & PEMUDAHCARAAN, PDPC)');            
         } else if ($j(this).text() == 'PedBA' || $j(this).text() == 'PedPIPQ') {			
	    $j('#perancangan-description > div').text('A. PEDAGOGI (ASPEK PERANCANGAN PEMBELAJARAN & PEMUDAHCARAAN, PDPC)');
	};
    });
});
AppGini 5.92 - Upgraded to 5.94

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: How to change the text of field description based on dropdown list selection

Post by pbottcher » 2021-02-26 22:00

Hi,

I guess you need to wait for the dropdown to be created first. Usually it is create a little bit later, so your script is executed, but does not find the container and hence does not work. If you try it in debug-mode, the dropdown is already there and it works.
Pls. search the forum as it was already described how to do that.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

ayussuf
Veteran Member
Posts: 39
Joined: 2021-01-20 17:15

Re: How to change the text of field description based on dropdown list selection

Post by ayussuf » 2021-02-26 23:44

Thank you for your response.

To achieve this, I've put the code in footer-extras.php. But it still not work.

What I wanna do is to create toggle switch between the first condition and the other condition..
AppGini 5.92 - Upgraded to 5.94

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: How to change the text of field description based on dropdown list selection

Post by pbottcher » 2021-02-27 08:40

Hi,
even in footer-extras the code is executed too early. You need to either wait for a certain time, or check for the dom element to exist and execute your code afterwards
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

ayussuf
Veteran Member
Posts: 39
Joined: 2021-01-20 17:15

Re: How to change the text of field description based on dropdown list selection

Post by ayussuf » 2021-02-27 11:06

pböttcher wrote:
2021-02-27 08:40
Hi,
even in footer-extras the code is executed too early. You need to either wait for a certain time, or check for the dom element to exist and execute your code afterwards
How do I make it or check the DOM element?

Sorry for asking this question. I'm very new in this matter.
AppGini 5.92 - Upgraded to 5.94

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: How to change the text of field description based on dropdown list selection

Post by pbottcher » 2021-02-27 11:53

Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

ayussuf
Veteran Member
Posts: 39
Joined: 2021-01-20 17:15

Re: How to change the text of field description based on dropdown list selection

Post by ayussuf » 2021-02-27 12:37

Thank you very much pböttcher
AppGini 5.92 - Upgraded to 5.94

Post Reply