Questions and discussion about using ProcessMaker 2: user interface, running cases and functionality
Forum rules: Please search to see if a question has already been asked before posting. Please don't ask the same question in multiple forums.
By Lawrence
#10881
Hi all,

Hope someone can help me, my js knowledge is quite limited and ive been on google all day looking for answers..

I want to have a button on my form that will allow users to hide and unhide certain fields on the form that are relevant.
I can do it the painstaking way.. by simplye switching back and forth from view to the editor.. But this form has about 50 fields that will need to be programmed for this.. and i have a feeling the client will ask me to add many more.. so ive tried to come up with a way to do it quickly..
The way i understand to hide and unhide via js.. is to use the following code:
Code: Select all
getField("MyField").parentNode.style.display='';
and to unhide:
Code: Select all
getField("MyField").parentNode.style.display='none';
Now the problem with this is depending on what field it is.. the parentNode will be different.. for example a text box may have .parentNode.parentNode, and a dropbox may have a .parentNode.parentNode.parentNode while a Main Title might have only one .parentNode

So i have been trying to use a window.prompt and with variables in my script to be able to look at my form from the preview, click the button, put the changing field name and test how many.parentNodes it has without having to switch everytime back to the js editor.. if i could get this working and figure it out it would save me fortunes of time for this project and future projects of PM as well..

Any assistance would be very very appreciated :)

Thanks in advance,
Lawrence
By Lawrence
#10889
Hi roelveldhuizen,

Yes I did. I needed more intelligence than the conditional editor was able to provide.

However i managed to make it happen!!

Life just became much easier hehe

showRow("MyField");
hideRow("MyField");

I just put all the fields into an array, loop through the array, and finito... JS coudlnt be easier now :)

Although now on to my next problem... :S

Thanks,
Lawrence
User avatar
By amosbatto
#782410
If you want to hide many fields at once, the easiest way to do this is place all the fields under a subtitle, then hide that subtitle with contractSubtitle(). For example if you have a checkbox field named "hideIt" which will hide all the fields under the subtitle named "mySubtitle", then you can use this JavaScript in your DynaForm:
Code: Select all
 function HideFields() {
    if (getField("hideIt").checked)
       contractSubtitle("mySubtitle");
    else    //if not checked
       expandSubtitle("mySubtitle");
 }
getField("hideIt").onchange = HideFields; //execute when checkbox changes 
HideFields(); //execute when DynaForm loads
By Indigo
#814351
I have tried to follow the same code but it didn't work. Processmaker would not load my dynaform. I am also trying to hide or show several fields when the user clicks on a radio button. here is the code i used.
Code: Select all
function HideFields() {
    if (getField("Yearswork").checked)
       contractSubtitle("Co-Maker");
    else
       expandSubtitle("Co-Maker");
 }
getField("Yearswork").onchange = HideFields;
HideFields(); 
User avatar
By amosbatto
#814368
"Co-Maker" is not a valid field name in ProcessMaker 2. You are probably using the field's label, not the name.
If you can't figure it out, post the XML code for your DynaForm and I will look at it.
Want to create your own meme coin?

In the world of cryptocurrencies, a unique and exc[…]

The market for cryptocurrencies is demonstrating a[…]

What's SAP FICO?

Embarking on a dissertation can be one of the most[…]

Hello. For rental housing, there are software solu[…]