top of page
Search
  • naveenaggarwal12

Change an item Label dynamically

Sometimes we need to change the label of an item dynamically based upon the value of some other item. Recently I came across this scenario and there I used a Dynamic Action running some JavaScript.


Today I am going to share the JS code and steps to implement the same.


I have two items P234_NATIONALITY and P234_OMANG_ID. I am changing the label text for P234_OMANG_ID item depending on the value chosen for item P234_NATIONALITY, which is a select list in my case.

The method uses jquery to search for a "label" tag with the attribute "for" that associates it with the desired item; we then naviagte down to "span" element and call the "text" function to change the label text.


The Dynamic action steps:


Event : Change

Selection Type : Item(s)

Item(s) : P234_NATIONALITY

Condition : (no condition)


True Action : Execute JavaScript Code

Fire on Page Load : Yes

Select Type : (blank)

Code : (the javascript shown below)


if ($v("P234_NATIONALITY")=='BW') { $("label[for=P234_OMANG_ID]").text("Omang ID") } else { $("label[for=P234_OMANG_ID]").text("Passport Number") }


This is a very simple code.


Please comment and let me know your thoughts or any other ways for it.




1,116 views0 comments

Recent Posts

See All
bottom of page